have you run the php artisan storage:link command?
Display Image from storage directory
Hi! Am so stuck, have tried several method but its not working.
The problem is: I cant display the user image from the storage/app/avaters on my page.
What I want to achieve is: Make it possible for users to upload their profile pictures.
What I have done so far
public function useravater(Request $request)
{
$avatar = request()->file('avatar');
$ext = $avatar->guessClientExtension();
$file = $avatar->store('avaters');
$user = User::where('id', Auth()->id())->update([
'img' => $file,
]);
return back();
}
The image gets upload to Storage/app/avaters verywell and updates the user img user column in the database. I have created also created a sym link: asset('storage/file.txt')
I use this code to display the image on my view
img src="{{asset('storage/'.Auth::user()->img)}}" alt="" class="user-image"
the image does not show up. This is what i get on the src="" when i check the console
src="http://stechmax.test/storage/avaters/LBP7fucsQoewdXypaARHxlC8jCo1MK47UJFUU3AZ.jpeg" alt="" class="user-image"
Yep I gat it fixed. following this stackoverflow ques. https://stackoverflow.com/questions/44045474/storing-and-retrieving-stored-file-in-laravel-5-4
asset('storage/avatars/avatar.jpg');
all I added is the storage
Thanks all.
Please or to participate in this conversation.