我仅使用md5哈希名称(不带扩展名)将文件保存在服务器中。我注意到,Storage::exists()
即使文件不存在,laravel方法也将返回true。实际上,laravel假定文件名为目录名。有什么办法可以迫使laravel检查文件是否存在?
实际上,这是因为PHP
sfile_exists
函数的工作方式。无论如何,您可能会使用如下所示的内容:
if(is_file('68e109f0f40ca72a15e05cc22786f8e6')) {
// ...
}
另外,您可以这样尝试glob
:
$all = glob('*'); // Read everything from current directory in array
if(in_array('68e109f0f40ca72a15e05cc22786f8e6', $all)) {
// ...
}
有更多方法可以执行此操作,但是为什么不使用扩展名呢?
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句