Images Not Showing From Storage Even After Running php artisan storage:link Hello, I am not able to show the image from the storage folder. I tried accessing the image from public folder and it's working fine.
But the image from public/storage/my-images/example.png displays 404 Error. I already run the 'php artisan storage:link' command as well.
What path are you trying to use to access the image? Can you show some code on how you accomplish this?
@bobbybouwmann
In Controller
$destination_path = 'public/images/profile-pictures/';
$profile_picture = $request->file('profile_picture');
$profile_picture_name = $user->username . '.' . $profile_picture->getClientOriginalExtension();
$profile_picture_url = 'storage/images/profile-pictures/' . $profile_picture_name; // to use in img src
$profile_picture->storeAs($destination_path, $profile_picture_name);
In View
<img src="{{ auth()->user()->profile_picture ? asset(auth()->user()->profile_picture) : asset('/storage/images/profile-pictures/default.jpeg') }}"
alt="{{ auth()->user()->name }}">
@Khin Zin Zin Thinn assuming you are using local driver. When retrieving assets from storage, use Storage facade like so
$url = Storage::url('file.jpg'), your code should be like this
<img src="{{ auth()->user()->profile_picture ? Storage::url(auth()->user()->profile_picture)) : Storage::url('images/profile-pictures/default.jpeg') }}"
alt="{{ auth()->user()->name }}">
Please sign in or create an account to participate in this conversation.