php - How to display Image saved in storage folder on blade

I would like to display an image saved in storage directory in a blade view. I am succesfully storing the file to the storage/app/public folder like so ProfilesController file:
`if(request('image')) {
$imagePath = request('image')->store('profile', 'public');
$image = Image::make(public_path("storage/{$imagePath}"))->fit(1000, 1000);
$image->save();
}
auth()->user()->profile->update(array_merge(
$data,
['image' => $imagePath]
));`
Now I would like to retrieve the image in my index.blade.php file. This is how have done it:
<img src="/storage/{{$user->profile->image}}" alt="">
The laravel documentation says use storage link in my terminal I did this
php artisan storage:link
I tried all that but there is no image loading to the view!
What am I doing wrong and how to fix!
Answer
Solution:
<img class="" src="{{ Storage::disk('name-option')->url('full path.jpg') }}" alt="">
disk('name-option') is option you can skip as
<img class="" src="{{ Storage::url('full path.jpg') }}" alt="">
Answer
Solution:
You should use Accessor in the User Profile Model i.e:-
public function getImageAttribute($image) { return asset('storage'.$image); }
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: dompdf image not found or type unknown
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.