@gustav1105 this line:
<img src="<?php echo asset("storage/app/$myTheory->image")?>"></img>
//should be changed to
<img src="<?php echo asset("storage/$myTheory->image")?>"></img>
then it will work.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I would like to display an image saved in storage directory in a blade view, with the path stored to the database
I am storing the file successfully to the storage/app/public folder and writing the path to the database like so
$imagePath = $request->file('image')->store('public');
$image = Image::make(Storage::get($imagePath))->resize(320,240)->encode();
Storage::put($imagePath,$image);
$myTheory->image = $imagePath;
Now I would like to retrieve the image to use in my index.blade.php file like so
<div class="panel-body">
{{ $myTheory->description }}
<!-- CODE GOES HERE FOR THE IMAGE SOURCE-->
<img src="storage/app/{{ $myTheory->image}}"></img>
<div class="panel-footer">
{{ $myTheory->updated_at }}
</div>
</div>
Obviously the above code does not work because I am trying to access the storage folder from the view
in my page source i have this
<img src="storage/app/public/9c9805d15667f17720ab79638e94b824.jpeg"></img>
The laravel documentation states use storage link in my terminal I did this
php artisan storage:link
The "public/storage" directory already exists.
This tells me the storage link has been created for storage\app\public and public\storage
further the laravel documentation states use the asset helper so in my blade file I did this but it does not work
<div class="panel-body">
{{ $myTheory->description }}
<img src="<?php echo asset("storage/app/$myTheory->image")?>"></img>
<div class="panel-footer">
{{ $myTheory->updated_at }}
</div>
</div>
and in the page source i get the full qualifying path to storage directory
<img src="http://dev.flatearthexperiment.com/storage/app/public/9c9805d15667f17720ab79638e94b824.jpeg"></img>
But there is no image loading to the view!
What am I doing wrong and how to fix!
See laravel documentation for what I used https://laravel.com/docs/5.3/filesystem#the-public-disk
navigate to public disk.
Any and all help welcome THANKS!
@gustav1105 this line:
<img src="<?php echo asset("storage/app/$myTheory->image")?>"></img>
//should be changed to
<img src="<?php echo asset("storage/$myTheory->image")?>"></img>
then it will work.
Please or to participate in this conversation.