按[]保存文件名,并将其插入Database by Controller Laravel

时间:2018-01-12 02:03:18

标签: laravel

我将文件上传到destinationPath,并且在我尝试为这些文件制作下载链接时,我在保存每个文件名方面遇到了问题。

foreach ($files as $file) {
  $fileName = now()->format('Y-m-d-H-i-s');
  $uploaded = Storage::put($destinationPath.$fileName.'.'.$file->getClientOriginalExtension(),file_get_contents($file->getRealPath()));
                    }
        if($uploaded){
            Project::create([
                'description' => $request->input('description'),
                'division' => $request->input('division'),
                'who' => $request->input('who'),
                'whom' => $request->input('whom'),
                'content' => $request->input('content'),
                'filename' => $division.'/'.$userName.'/'.$fileName
            ]);
        }

0 个答案:

没有答案