【发布时间】:2022-01-15 22:36:07
【问题描述】:
我通过laravel 创建了一个网站,该网站在本地运行良好,如果存在则显示图像,如果图像不存在则显示not-found.jpg 图像,并且当我在线托管时 [aswaktinghir.com][1],总是显示not-found.jpg 图像,productImage 函数总是转到第二个图像条件not-found.jpg,即使有图像。
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 class="col-md-3 col-xs-12">
<div class="blog-item this-animate" data-animate="fadeInUp">
<div class="blog-media">
<img src="{{ asset(productImage($annonce->image) )}}" class="img-responsive" style="width: 240px;height: 240px" />
</div>
<div class="blog-data">
<h5>{{ $annonce->details }}</h5>
<span class="blog-date">{{ $annonce->created_at }} / 0 Comments</span>
<p>{{ substr($annonce->description, 0, 31) }}...</p>
</div>
</div>
</div>
</a>
@endforeach
</div>
【问题讨论】:
-
您是否创建了存储符号链接?
-
@TipuSultanEiko 是的,我创建符号链接,我编辑我的函数以`return $path && file_exists('storage/'.$path) ? asset('storage/'.$path) : asset('storage/'.$path);` ,你可以再次看到我的网站link
-
你检查服务器路径了吗?那些文件存在吗?
-
@TipuSultanEiko 有些图片存在,有些不存在