Laravel存储符号链接 [英] Laravel Storage symlink

查看:149
本文介绍了Laravel存储符号链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试访问存储在storage/app/.../.../file.png中的文件.

I'm trying to access files that are stored in storage/app/.../.../file.png.

我创建了一个符号链接,将我的存储文件夹链接到public/storage.

I have created a symlink, linking my storage folder to public/storage.

当我尝试访问适当的文件时,我的服务器抛出404,表示找不到文件.显然,我没有以正确的方式访问它,但我不知道要更改什么.

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.

<img src="{{asset('storage/app/puppy/18/ax2Fk08nyWrV6TwTOnsXNCkNGuIdFebB7TTfPYGb.png')}}" alt="">

推荐答案

laravel中创建符号链接时,它会创建storage/app/public文件夹到public/storage文件夹的符号链接.这意味着,如果您要公开访问任何文件,则将所有文件放在storage/app/public文件夹中,并按如下方式访问它

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

<img src="{{asset('storage/puppy/18/test.png')}}" alt="">

此处表示文件test.png应该物理上位于storage/app/public/puppy/18文件夹中.

Here it means the file test.png should be physically at storage/app/public/puppy/18 folder.

执行php artisan storage:link在laravel中创建符号链接

Execute php artisan storage:link for creating symlink in laravel

希望您能清楚

这篇关于Laravel存储符号链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆