Laravel:检查文件是否存在,没有扩展名


Laravel: check file existence without extension

我将文件保存在服务器中,只有md5散列名称没有扩展名。我注意到laravel Storage::exists()方法将返回true,即使文件不存在。实际上,laravel假定文件名为目录名。有没有办法强制laravel检查文件是否存在?

实际上,这是因为PHPfile_exists函数的工作方式。无论如何,你可以这样使用:

if(is_file('68e109f0f40ca72a15e05cc22786f8e6')) {
    // ...
}

同样,您可以像这样尝试glob:

$all = glob('*'); // Read everything from current directory in array
if(in_array('68e109f0f40ca72a15e05cc22786f8e6', $all)) {
    // ...
}

有更多的方法来做到这一点,但为什么不使用扩展?