2016-06-12 50 views
0

當我想移動一個文件laravel給了我一個錯誤,我不明白爲什麼。Laravel 5.2 - 文件未找到(雖然它在那裏);

這是錯誤我收到

local.ERROR: exception 'League\Flysystem\FileNotFoundException' with message 'File not found at path: Ad_Pictures/waitinglist/6f6232707e65c7803f7af248a07cb8cesony-z5-familytn videos ad.jpg'

然而,當我看到在服務器上它天內文件是存在的(這是第4一個

#4

這裏是我的我用來移動文件的代碼

 $newAd = DB::table('ads')->orderBy('created_at', 'desc')->first(); 
     $Ad = Ad::find($newAd->id); 

     $oldDestination_path = "Ad_Pictures/waitinglist/"; 
     $newDestination_path = "Ad_Pictures/".$newAd->id."/"; 

     if(!is_dir($newDestination_path)) 
     { 
      mkdir($newDestination_path); 
     } 
     Storage::move($oldDestination_path.'/'.$file, $newDestination_path.'/'.$file); 

他使新目錄沒有問題,他只是不移動文件。

+1

屏幕截圖被裁剪 - 顯示的是哪個目錄 - 是Ad_Pictures/waitinglist還是/ Ad_Pictures /? – herrjeh42

+0

並且:你是否對文件名中沒有空格的文件嘗試了相同的代碼?你永遠不會知道...... ;-) – herrjeh42

+0

嘗試轉儲dedtination和名稱變量,我的東西laravel是在存儲文件夾中的lookibg,而你在公共foldef文件 –

回答

0

完整的代碼沒有顯示,但我會告訴你,默認情況下,文件夾是存儲/應用程序,你需要從那裏獲得文件 如果你的文件位於其他地方,你可以在config/filesystems中創建自己的磁盤例如'myDisk' => [ 'driver' => 'local', 'root' =>base_path('xyzFolder'), ],

,你可以這樣調用它

use Illuminate\Support\Facades\Storage; 

$data = Storage::disk('myDisk')->get('myFile.txt'); 

這顯然是獲取文件,您可以通過以下laravel文檔執行任何其他功能。

相關問題