Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

M.Yanis's avatar

Can't display image using storage

Hi everyone I have a little problem when I want to display an image. My image is stored in " storage/app/public/posts"

 <header class="masthead" style="background-image: url('/storage/{{ $post->image }}')">


 $post->image = "posts/1635760084913_276449.jpg"

This is my filesystem.php ​

 'disks' => [

        'local' => [
            'driver' => 'local',
            'root' => storage_path('app'),
        ],

        'public' => [
            'driver' => 'local',
            'root' => storage_path('app/public'),
            'url' => env('APP_URL').'/storage',
            'visibility' => 'public',
        ],

        's3' => [
            'driver' => 's3',
            'key' => env('AWS_ACCESS_KEY_ID'),
            'secret' => env('AWS_SECRET_ACCESS_KEY'),
            'region' => env('AWS_DEFAULT_REGION'),
            'bucket' => env('AWS_BUCKET'),
            'url' => env('AWS_URL'),
            'endpoint' => env('AWS_ENDPOINT'),
            'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
        ],

    ],

    'links' => [
        public_path('storage') => storage_path('app/public'),
    ], 

I have already done the link storage: link

0 likes
18 replies
Nakov's avatar

have you tried like the documentation says: https://laravel.com/docs/8.x/filesystem#the-public-disk

{{ asset('storage/'. $post->image ) }}

so it will be:

style="background-image: {{ asset('storage/'. $post->image ) }}"

you are using url() helper out of PHP, so that's why you won't see the image.

Even this might work:

 <header class="masthead" style="background-image: {{ url('/storage/' .$post->image)}}">
M.Yanis's avatar

@Nakov same ... I don't understand, I had no problem when I launched my application on my linux machine but when I have changed OS(windows) I can't display my images

Nakov's avatar

@M.Yanis different OS different permissions and what not..

And is the image available on the disk? If you go in your public folder, do you see a storage folder as well? Maybe the storage:link didn't worked because of permission issues.

M.Yanis's avatar

@Nakov When I run php artisan storage: link I get :

  • The [C: \ wamp64 \ www \ Personal Projects \ Blog \ public \ storage] link already exists.
  • The links have been created.

And this is my storage folder :

  > storage
     > app
        > public 
          > posts
               1635760084913_276449.jpg
Sinnbeck's avatar

What is your the root url of your project?

Sinnbeck's avatar

@M.Yanis Can you open the image in a browser if you go to

C:\wamp64\www\Personal Projects\Blog\public\storage\posts\1635760084913_276449.jpg

M.Yanis's avatar

@Sinnbeck Yes I can, when I type on my browser C:\wamp64\www\Personal Projects\Blog\public\storage\posts\1635760084913_276449.jpg the image appears

Snapey's avatar

using your file explorer, confirm that you see the same files and folders in /public/storage and /storage/app/public

M.Yanis's avatar

@Snapey In my storage folder I have all my images stored in database. But in my public folder i don't have storage folder

This is my storage folder :

 > storage
     > app
        > public 
          > posts
               1635760084913_276449.jpg
               and all my ithen images...

And this is my public folder :

> public 
  > css
  > js
  > img
  > htaccess
  > htaccess
  > storage ( just a system file not folder)
  > web.config

When I run php artisan storage:link I get :

- The [C: \ wamp64 \ www \ Personal Projects \ Blog \ public \ storage] link already exists.
- The links have been created.
M.Yanis's avatar

@Snapey No, using my file explorer, I don't have a storage folder in public, just file system "storage"

Snapey's avatar

@M.Yanis Then the symlink is not set. This would be the case if you are trying to do this on windows and not running WSL. Not sure if a shortcut can behave the same

M.Yanis's avatar

Thanks for your help.

as I was using linux I had a symlink which worked fine on linux but as soon as I launched my application on windows I saw a system file named storagein my public folder so I had to delete it and run php artisan storage: link and now it works

oreofe_unlimited's avatar

Laravel storage filesystem is so unique. Any file upload will be stored in the storage/app/public directory. To make it accessible in public directory, things you need to do is to the create symlink by running the command:

php artisan storage:link

This command will symlinked storage/app/public to public/storage

Just follow the https://laravel.com/docs/10.x/filesystem#the-public-disk about how to upload and how to retrieve the file url. I am pretty sure the step you are missing is creating the symlink.

Hope it helps.

Please or to participate in this conversation.