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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 17:57:05  来源:igfitidea点击:

Laravel Storage symlink

phplaravelsymlink

提问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="">

enter image description here

在此处输入图片说明

回答by rkj

when you create symlink in laravelthen it create symlink of storage/app/publicfolder to public/storagefolder. That means if you want to access any files publicly then place all your files inside storage/app/publicfolder 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.pngshould be physically at storage/app/public/puppy/18folder.

这意味着文件test.png应该物理地位于storage/app/public/puppy/18文件夹中。

Execute php artisan storage:linkfor 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="">