鍍金池/ 問答/PHP  Linux  數(shù)據(jù)庫  HTML/ laravel ftp使用storage怎么判斷文件是否存在

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']被我在測試階段已經(jīng)把文件刪除了,但是我想在刪除該文件時我想判斷該文件是否存在,不管我用Storage::get(),Storage::size()還是file_exists()等函數(shù),
clipboard.png
他都會報出如上圖的錯誤,我現(xiàn)在只向讓他返回true or false,如果判斷文件存在我在刪除這個文件,不存在就不做任何操作,請問怎么用哪個函數(shù)進行判斷ftp上面的文件是否存在,我查文檔上面刪除都沒有進行判斷是否存在,請問大佬們該怎么做

回答
編輯回答
骨殘心

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

2018年7月30日 17:45