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

Vinciepincie's avatar

linking /public and /storage doesn't work

Hello, I have a form where i can upload an image. The image successfully uploads to storage/app/public/img I want to display it in the view and that doesn't work even though i did "php artisan storage:link". Is it not linked properly or did i do something else wrong? Thanks.

The store() method in the controller:

    public function store(Request $request) {
        $title = $request->input('title');
        $summary = $request->input('summary');
        $description = $request->input('description');
        $path = $request->file('image')->store('public/img');

        $project = new Project;
        $project->title = $title;
        $project->summary = $summary;
        $project->description = $description;
        $project->image_name = $path;
        
        $project->save();
        return redirect('/projecten');
    }

The view with the image

            @foreach ($projects as $project)
				//
                        <img class="card-img" src="{{asset('storage/'.$project->image_name )}}" />
            @endforeach

The view with image in the browser:

<img class="card-img" src="http://homestead.test/storage/public/img/2v1pbmXPd9Zsh74UE7DB3ReQ8pHH0ueDEwXrZlBR.png">

config/filesystems.php:

    'links' => [
        public_path('storage/img') => storage_path('app/public/img')
    ],
1 like
9 replies
MohamedTammam's avatar
<img class="card-img" src="{{Storage::url($project->image_name)}}" />
1 like
Vinciepincie's avatar

@MohamedTammam Thanks for the reply. Unfortunately it still doesn't show an image. This is what happens in the browser:

<img class="card-img" src="/storage/img/2v1pbmXPd9Zsh74UE7DB3ReQ8pHH0ueDEwXrZlBR.png"> 

if i type the url homestead.test/storage/img/2v1pbmXPd9Zsh74UE7DB3ReQ8pHH0ueDEwXrZlBR.png it shows 404 not found too.

1 like
Snapey's avatar

look in the public/storage folder. Can you see the file? In the img folder?

Just browse the folder with your file manager and see what the real path is.

1 like
Vinciepincie's avatar

In public/storage i can see the img folder (but it's empty) https://i.imgur.com/JnPWwbb.png

1 like
MohamedTammam's avatar

@Vinciepincie It looks like your storage:link isn't working.

Try to delete 'public/storagedirectory then runphp artisan storage:link` again.

1 like
Vinciepincie's avatar

@MohamedTammam Doesn't work unfortunately

   ErrorException

  symlink(): Protocol error

  at vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php:332
    328▕      */
    329▕     public function link($target, $link)
    330▕     {
    331▕         if (! windows_os()) {
  ➜ 332▕             return symlink($target, $link);
    333▕         }
    334▕
    335▕         $mode = $this->isDirectory($target) ? 'J' : 'H';
    336▕

      +15 vendor frames
  16  artisan:37
      Illuminate\Foundation\Console\Kernel::handle()

I'm using windows 11 with homestead

1 like

Please or to participate in this conversation.