[英]Laravel says file does not exist but it does
I have this line: 我有这条线:
$local_document_path = storage_path() . "/app/file/myfile.pdf";
$myfile = Storage::get($local_document_path);
And I get a FileNotFoundException error. 而且我收到FileNotFoundException错误。
Now I checked the variable and seems correct, and I double checked again by copying the path to clipboard and pasting it: 现在,我检查了该变量并看上去是正确的,然后通过将路径复制到剪贴板并将其粘贴来再次检查了一次:
dd($local_document_path == $copypasted_path)
It returns true. 它返回true。 This means that the path is 100% correct, yet it does not work with storage. 这意味着该路径是100%正确的,但不适用于存储。 I have also tried by removing storage_path();
我也尝试过删除storage_path();
and it does not work either. 而且也不起作用。
Any help? 有什么帮助吗?
Thanks in advance. 提前致谢。
Your Storage::get
calls should use a path relative to the root of the storage disk. 您的Storage::get
调用应使用相对于存储磁盘根目录的路径。 The default storage disk is configured to be storage_path('app')
, so you'll need Storage::get('file/myfile.pdf')
. 默认存储磁盘配置为storage_path('app')
,因此您需要Storage::get('file/myfile.pdf')
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.