File uploading in Laravel

后端 未结 1 1944
日久生厌
日久生厌 2021-01-29 05:20

Been trying tons of things to save a file upload into the proper directory in Laravel. I have the following in my controller. The $files and $folder variables are correct. Th

相关标签:
1条回答
  • 2021-01-29 05:59

    you should try this code. error in your storage::disk line. write driver instead of drivers.

        $files = $request->file('current_plan_year_claims_data_file_1');
        $folder = public_path(). "\storage\\$id";
    
    
         if (!File::exists($folder)) {
            File::makeDirectory($folder, 0775, true, true);
        }
    
        if (!empty($files)) {
            foreach($files as $file) {
                 Storage::disk(['driver' => 'local', 'root' => $folder])->put($file->getClientOriginalName(), file_get_contents($file));
            }
        } 
    
    0 讨论(0)
提交回复
热议问题