2016-06-12 69 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文档执行任何其他功能。