woxene's avatar

Displaying an image from the local disk.

I have an image upload that uploads to the local disk :

//This one;
'disks' => [
    'local' => [
        'driver' => 'local',
        'root' => storage_path('app'),
    ],
],

And the file gets stored in the current location:

(rootfolder)\storage\app\carrier_logo\ ycWmHb2RtjYNIcj1w5CzzNLw1gA5rtz7u552Js2A.png

//Filetree of this location:
+---app
|   |   .gitignore
|   |
|   +---carrier_logo
|   |       ycWmHb2RtjYNIcj1w5CzzNLw1gA5rtz7u552Js2A.png //This is the file i want to show.
|   |
|   \---public
|           .gitignore
|

Now I want to display this image in my template. But I can't seem to fetch the image.

0 likes
1 reply
Cronix's avatar

It's best to use the default public disk there, and run the php artisan storage:link command to create the symlink to the actual /public dir (which is publicly accessible). You can't directly link to the /storage dir since that's outside of the DocumentRoot of the site (/public).

I'm assuming you want to display it regularly like <img src="/path/to/image"> and not something you're retrieving and sending to the browser directly.

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

Please or to participate in this conversation.