laravel ftp使用storage怎么判断文件是否存在

1.在config文件夹下filesystems.php设置ftp Host,username和password

clipboard.png
2.
clipboard.png
collect($results)->map(function($result) use($table){

        file_put_contents(PUBLIC_PATH()."/logs/path.txt", date("Y-m-d H:i:s").'---'.$result['id'].'---'.$result['capture_photo_path'].'---'.$result['face_photo_path'].'\r\n', FILE_APPEND);
        // dd(\Storage::size($result['capture_photo_path']));
        dd(\Storage::get($result['capture_photo_path']));
        if(\Storage::size($result['capture_photo_path'])){
            dd(123);
            // \Storage::delete($result['capture_photo_path']);         
        }else {
            dd(222);
        }
    });

图中的$result['capture_photo_path']被我在测试阶段已经把文件删除了,但是我想在删除该文件时我想判断该文件是否存在,不管我用Storage::get(),Storage::size()还是file_exists()等函数,
clipboard.png
他都会报出如上图的错误,我现在只向让他返回true or false,如果判断文件存在我在删除这个文件,不存在就不做任何操作,请问怎么用哪个函数进行判断ftp上面的文件是否存在,我查文档上面删除都没有进行判断是否存在,请问大佬们该怎么做

阅读 6.2k
1 个回答

storage::exists($results['capture_photo_path'])就好了;

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题