文件上传目标路径未上传

时间:2018-08-29 08:31:43

标签: laravel eloquent

  

问题是我的存储无法正常工作。它没有将我的文件上传到destinationPath中。当我添加文件路径时,它没有目的地。

Controller @ store

$destinationPath = config('app.filesDestinationPath').'/'.$bank.'/'.$username.'/'.$date.'/';        
foreach ($files as $file) {
   $filename = $file->getClientOriginalName();
   Storage::put($destinationPath.$filename.'.'.$file->getClientOriginalExtension(),file_get_contents($file->getRealPath()));
}

Controller @ show

$directory = config('app.filesDestinationPath').'/'.$bank->$bank.'/'.$bank->username.'/'.$bank->date.'/';
$files = Storage::files($directory);
dd($files);
return view('banks.show', ['bank'=>$bank])->with(array('files' => $files));

配置/应用

'fileDestinationPath' => 'uploads',
'allowedFileTypes' => 'jpg,jpeg,bmp,png',
'maxFileSize' => 1000000*2,

配置/文件系统

public' => [
 'driver' => 'local',
 'root' => storage_path('app/public'),
 'url' => env('APP_URL').'/storage',
 'visibility' => 'public',
],

1 个答案:

答案 0 :(得分:1)

App \ Filesystems.php

'local' => [
    'driver' => 'local',
    'root' => resource_path('app');
],