我想检索使用存储的所有文件的公共网址
存储::putFile('公共/备件');
所以,这是我正在使用的问题
存储::文件('公共/备件');
但它提供了 laravel 存储目录的输出
public/spares/image1.jpg
public/spares/image2.jpg
public/spares/image3.jpg
我如何获得上述内容的公共链接
http://localhost/laravel/public/storage/spares/image1.jpg
http://localhost/laravel/public/storage/spares/image2.jpg
http://localhost/laravel/public/storage/spares/image3.jpg
**编辑 **
发送文件的最后修改数据以供查看
$docs = File::files('storage/document');
$lastmodified = [];
foreach ($docs as $key => $value) {
$docs[$key] = asset($value);
$lastmodified[$key] = File::lastmodified($value);
}
return view('stock.document',compact('docs','lastmodified'));
它是否正确
首先,您必须从您的public/storage
目录到你的storage/app/public
目录,以便您可以访问这些文件。您可以通过以下方式做到这一点:
php artisan storage:link
那么您可以使用以下方式存储您的文档:
Storage::putFile('spares', $file);
并通过以下方式将它们作为资产访问:
asset('storage/spares/filename.ext');
查看公共磁盘上的文档 https://laravel.com/docs/5.4/filesystem#the-public-disk
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)