phplaravellaravel-5laravel-5.8

How to fix GET http://localhost/storage/users/default.jpg 404 (Not Found) in laravel


I'm facing a problem that return me :
GET http://localhost/storage/users/default.jpg 404 (Not Found).

I have storage link (a shortcut) created and a users/default.jpg file in it.
I've called it in blade like this :
{{Storage::disk('public')->url('users/'. Auth::user()->image)}}.

But it's not working. Any one can help me? How can i fix this issue. I can't find the problem.

My code :

<div class="user-pic">
   <img src="{{Storage::disk('public')->url('users/'. Auth::user()->image)}}" alt="users" class="rounded-circle" width="50" />
</div>

Solution

  • After running the command php artisan storage:link, you'll end up accessing your assets files in the storage directory using this syntax : asset('storage/file.txt');

    If you wish access it inside a blade template, you'll write something like this :

    <img src= "{{ asset('storage/users/' . Auth::user()->image) }}">