Laravel 存储符号链接
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/51676037/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel Storage symlink
提问by Vranvs
I'm trying to access files that are stored in storage/app/.../.../file.png.
我正在尝试访问存储在 storage/app/.../.../file.png 中的文件。
I have created a symlink, linking my storage folder to public/storage.
我创建了一个符号链接,将我的存储文件夹链接到公共/存储。
When I try to access the appropriate file, my server throws a 404, saying file not found. Clearly I'm not accessing it the right way but I dont know what to change.
当我尝试访问适当的文件时,我的服务器抛出 404,说找不到文件。显然我没有以正确的方式访问它,但我不知道要改变什么。
<img src="{{asset('storage/app/puppy/18/ax2Fk08nyWrV6TwTOnsXNCkNGuIdFebB7TTfPYGb.png')}}" alt="">
回答by rkj
when you create symlink in laravel
then it create symlink of storage/app/public
folder to public/storage
folder. That means if you want to access any files publicly then place all your files inside storage/app/public
folder and access it like this
当您在laravel
其中创建符号链接时,它会创建storage/app/public
文件夹到public/storage
文件夹的符号链接。这意味着如果您想公开访问任何文件,请将所有文件放在storage/app/public
文件夹中并像这样访问它
<img src="{{asset('storage/puppy/18/test.png')}}" alt="">
Here it means the file test.png
should be physically at storage/app/public/puppy/18
folder.
这意味着文件test.png
应该物理地位于storage/app/public/puppy/18
文件夹中。
Execute php artisan storage:link
for creating symlink in laravel
执行php artisan storage:link
以在 Laravel 中创建符号链接
Hope it clear you
希望你清楚
回答by Jesus Erwin Suarez
Try this one.
试试这个。
<img src="{{asset('puppy/18/ax2Fk08nyWrV6TwTOnsXNCkNGuIdFebB7TTfPYGb.png')}}" alt="">