[英]Issue getting a file with Laravel
Hi I do not know what is happening but I want to get a file from the storage folder and it says that it does not existe but it exists I mean I go to the folder and it is there..嗨,我不知道发生了什么,但我想从存储文件夹中获取一个文件,它说它不存在,但它存在我的意思是我去那个文件夹,它就在那里..
I retrieve the file like this:我像这样检索文件:
$path = storage_path('app/public/' . $settlement->support);
$settlement_file = Storage::disk('local')->get($path);
And I get this error:我得到这个错误:
message: "File not found at path:
home/jysparki/newjis.jisparking.com/storage/app/public/06152617_8-2025.pdf"
and If I go to the folder it exists so I wonder what am I doing wrong?如果我转到它存在的文件夹,那么我想知道我做错了什么? Thanks.谢谢。
If you look at config/filesystems.php
file and find disks
array, you may notice that root
under the local
disk key is set to storage_path('app')
.如果您查看config/filesystems.php
文件并找到disks
阵列,您可能会注意到local
磁盘密钥下的root
设置为storage_path('app')
。 Well it's up to what the value may be in your case you're free to change it, but what does this mean is whenever you call Storage::disk('local')
method it will try to find files relative to storage_path('app')
, so there is no need to specify full path.好吧,这取决于您的情况可能是什么值,您可以自由更改它,但这意味着每当您调用Storage::disk('local')
方法时,它都会尝试查找相对于storage_path('app')
,因此无需指定完整路径。 Try this instead试试这个
$settlement_file = Storage::disk('local')->get('/public/' . $settlement->support);
or或者
$settlement_file = Storage::disk('public')->get($settlement->support);
as Laravel by default has public
disk which pointed into /app/public
storage directory因为 Laravel 默认有指向/app/public
存储目录的public
磁盘
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.