I'm working with Laravel latest version and I want to show an image like this:
<img src="{{ asset('storage/'.$media->med_path) }}" alt="Thumbnail" style="width: 100px; height: auto;">
And when I see the source code it adds this value to src
attribute of image tag:
http://localhost:8000/storage/public/medias/jpg/57N8MJmsp2y8P0aexysV_200x200.jpg
But the image itself not showing up somehow:
Here is also the value of variable ($media->med_path
) in the DB:
public/medias/jpg/57N8MJmsp2y8P0aexysV_200x200.jpg
However I have already ran the command php artisan storage:link
and the links are already exists via this filesystems.php
config file:
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
'throw' => false,
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
'throw' => false,
],
...
'links' => [
public_path('storage') => storage_path('app/public'),
],
And the image already exists in this directory of my project:
-project
-storage
-app
-public
-medias
-jpg
-57N8MJmsp2y8P0aexysV_200x200.jpg
So what's going wrong here? How can I solve this issue and show the image properly?
you can reach to storage from public link from
http://localhost:8000/storage/medias/jpg/57N8MJmsp2y8P0aexysV_200x200.jpg
you shouldn't get storage directly
when you store image url in DB store link like
storage/medias/jpg/57N8MJmsp2y8P0aexysV_200x200.jpg
and when you want to get it in blade get it like this:
<img src="{{ asset($media->med_path) }}" alt="" />