Now, I working on Laravel project but i got some issue in this project. I stored image name in database and also store in storage folder but images are not show in my dashboard
Blade file code:
<div class="col-sm-8">
<a href="blog_detail/{{ $main_blog->id }}">
<img src="<?php echo asset("../storage/app/assets/upload/images/$main_blog->image")?>" class="blog_img">
<h1 class="blog_main_heading">{{ $main_blog->title }}</h1>
</a>
</div>
6
Answers
Show your image uri in the web page, copy and paste image uri to check image uri is correct
Did you use
php artisan storage:link
?I can’t see your folder structure, hope it works though, Please check below code:
if your image
storage path
is like this then this will work for you.public/assets/images/default.png
instead of images use your path and try . Please check image exists in your server
First, It is worthwhile to mention that your code is a bad practice. It would be better to do something like this in the controller, say
ImageController
Then in blade
and about the problem, you should inspect the missed images and see what the url is. Check whether it works with
/public
suffix in url or not. Let us see thefilesystem.php
. This is mineAppropriately set this file and make sure storage link is ran on the production server. Anyway, we need more details to debug your problem.
First,
asset()
helper is based on your APP_URL, means you are trying to access storage path directly, that won’t work because you cannot access out of public folder.So, make sure you done
php artisan storage:link
whens you doing that it will create a link from your storage to public, and you can see storage folder under your public folder, then you can just use like thisasset('storage/app/assets/upload/images/filename.png')
.If you didn’t find storage folder in your public folder that means your link build failed.