ONY*_*NYX 0 php laravel laravel-5
我想知道你是否在我的代码中执行以下操作,如何检查文件是否存在,例如
{
$file = Storage::disks('local')->get($file);
// then test if $file exists
}
Run Code Online (Sandbox Code Playgroud)
您可以使用以下代码检查文件是否存在,以用于本地存储,
$file_exists = Storage::disk('local')->exists($file);
Run Code Online (Sandbox Code Playgroud)
您可以在Laravel Filesystem上阅读有关Laravel Document上存储的更多信息.
注意:在文档中,您将检查disk('s3').这取决于我们使用的连接config/filesystem.php(laravel中文件系统的配置文件).
或者只是你可以使用检查条件
if(Storage::disk('local')->exists($file)) {
}
Run Code Online (Sandbox Code Playgroud)
它也适合你.