Home > other >  How can I access image in public folder Laravel?
How can I access image in public folder Laravel?

Time:11-06

I want to know how to access image in public folder of Laravel I found the two ways:

{{asset('/folder name of the stored files inside public folder Laravel/'.$variable->filename}}
For example:- {{ asset('/images/products/'.$value->product_image) }}

and

{{ URL::to('/'}}/folder name of the stored files inside public folder Laravel/'.$variable->filename
For Example:-   {{ URL::to('/'}}/images/$value->product_image

But I not understand. where come this $variable
Can someone explain me the logic of this with some example?

CodePudding user response:

You can create a symbolic link to your public directory as shown in the laravel documentation.

https://laravel.com/docs/8.x/filesystem#the-public-disk

Once this has been done, you can use

asset('storage/file.txt');

to create an url for that image.

  • Related