Laravel图像未显示在服务器上,并且在我的本地计算机上工作正常 [英] Laravel image not shown on server and working fine on my local machine
本文介绍了Laravel图像未显示在服务器上,并且在我的本地计算机上工作正常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的本地机器项目工作文件上,但是当我将其上传到服务器时,则不会显示所有图像,当我点击浏览器的完整图像路径时,NotFoundHttpException错误.
On my local machine project working file but when i uploaded on my server then all images are not shown, and NotFoundHttpException error when i hit full image path to browser.
项目的mypath为
/public_html/offlinemall/public
下面是我的filesystems.php
And Below is my filesystems.php
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
's3' => [
'driver' => 's3',
'key' => env('AWS_KEY'),
'secret' => env('AWS_SECRET'),
'region' => env('AWS_REGION'),
'bucket' => env('AWS_BUCKET'),
],
'featured' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
],
我如何获得图像
<img style="height: 480px" src="storage/{{ $ad->avatar }}">
在检查中,我得到了完整的路径,但是当我点击url时,我收到了NotFoundHttpException错误.
In inspect i get full path but when i hit url then i get NotFoundHttpException error.
http://compare.theofflinemall.com/storage/featured_image/qzHWpQeSfKjZ6DOS59ROyYboJ1GCvVi6NNVfLtVV.jpeg
推荐答案
您的服务器无法找到存储
作为路径,因为它使用了 public_path
运行
Your server can't locate storage
as path because it uses public_path
run
php artisan storage:link
应该可以.另外,尝试使用
It should work. Also, try to use
{{ asset('storage/'.$ad->avatar) }}
这篇关于Laravel图像未显示在服务器上,并且在我的本地计算机上工作正常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文