i created a website by laravel
, site works fine locally, it displays image if exist, and displays not-found.jpg
image if image not exist, and when i host it online [aswaktinghir.com][1],always display not-found.jpg
image, the productImage
function always goes to the 2nd image condition not-found.jpg
, even there is an image.
helpers.php
function productImage($path)
{
return $path && file_exists('storage/'.$path) ? asset('storage/'.$path) : asset('img/not-found.jpg');
}
landing-page.blade.php
@foreach($annonces as $annonce)
<a href="{{ url('annonces/'.$annonce->id) }}">
<div >
<div data-animate="fadeInUp">
<div >
<img src="{{ asset(productImage($annonce->image) )}}" style="width: 240px;height: 240px" />
</div>
<div >
<h5>{{ $annonce->details }}</h5>
<span >{{ $annonce->created_at }} / 0 Comments</span>
<p>{{ substr($annonce->description, 0, 31) }}...</p>
</div>
</div>
</div>
</a>
@endforeach
</div>
CodePudding user response:
If you are using Git to transfer files to your production server, make sure to take a look in your .gitignore file in the root directory. Make sure you are not excluding the /store or /public/store folders.
CodePudding user response:
have you tried
chmod -R 755 [path to storage]
chown -R www-data:www-data [path to storage]