在 laravel 中,我使用 php artisan 创建了存储,我无法访问刀片上的图像,上传工作正常,但我什至看不到它们的文件,它们已损坏。即使使用
http://localhost:8000/storage/ProductId-1601294060.jpg
laravel 响应也未找到,但图像存在于文件夹中
我尝试过的步骤
<td><strong><img src="/storage/product_image/ProductId-1601296148.jpg" height="150px" width="150px"/></strong></td>
步骤2
<td> <img src="{{ URL::asset('/storage/product_image/ProductId-1601296148.jpg') }}" ></a></td>
步骤3
<td><img src="{{asset('/storage/product_image/ProductId-1601296148.jpg')}}" class="img-size-50 mr-3 img-circle"></td>
也在文件配置文件系统中我添加了
'default' => 'public'
谢谢
请尝试在公共文件夹中创建符号链接,之后您将能够访问图像 您可以阅读更多这里
php artisan storage:link
我认为你的问题是你使用的是
asset(/storage..)
而不是 asset('storage...)
Laravel 存储文件系统非常独特。当您进行任何上传时,它将上传到 storage/app/public 目录中。为了使其可以在公共目录中访问,需要做的是通过运行命令创建符号链接:
php artisan storage:link
或者
<img src="{{ Storage::url("/product_image/ProductId-1601296148.jpg") }}" alt="" />
对于遇到此类问题的人,请尝试运行
rmdir 公共\存储
然后
php artisan 存储:链接