php - PHP/Laravel:存储::磁盘()。提供真实,但不应该
问题描述
Laravel 5.2 我不明白。我正在检查文件夹中是否存在文件。没有文件,但我得到true
.
我尝试了不同的方法,例如:
Storage::disk('local')->exists($path_to_json . array_first($text['other'])); //true
Storage::disk('local')->has($path_to_json . array_first($text['other'])); //true
if(file_exists($path_to_json . array_first($text['other']))) //always false, even if file is there
dd($path_to_json) // "list/text-1a/"
filesystems.php
看起来不错,我可以将文件上传到我需要的地方。
'default' => ('local'),
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],
有人有同样的问题吗?我读过一些主题,有相反情况的人,当文件在文件夹中时他们会得到错误。
更新。Storage::disk
如果我可以这么说,“错误”是合乎逻辑的。或者在我的脑海里。
$text['other']
has preg_grep
,它检查文件扩展名。排除txt和png。
Storage::disk
看到,有 txt 文件和 retuns TRUE
。但我正在检查其他没有 txt 或 png 的文件。这就是为什么必须稍微重构验证的原因:
Storage::disk('local')->exists($path_to_json . $id . '_datafile.json');
在这里,我们正在寻找扩展名为 JSON 的特定文件。这就是问题所在。如果我把自己说清楚,我会很高兴。
解决方案
推荐阅读
- html - 标签 id 和 aria-labelledby 的区别用法
- python - 导入一个未打包模块的python类,并在它自己的线程中运行
- javascript - 如何从数组中获取所有元素
- flutter - 使用颤动中的动画更改对象形状
- sql - 如何使用 ORDER BY RIGHT() 对列进行排序
- node.js - Node Express 访问 rawBody
- python - NaT 在尝试删除时间时返回?
- kubernetes - Kubernetes:多域设置和负载均衡器/入口策略
- javascript - 未捕获的类型错误:无法读取 null 的属性“innerText”,但它不为 null
- python - TensorFlow Ragged Boolean Mask 将常量维度设置为无