Laravel 5文件""不存在

时间:2016-02-17 12:09:16

标签: php laravel laravel-5

我试图上传文件。继承人我的控制器

if ($request->hasFile('photo')) {
            $destinationPath = 'images/quizzes/'; // upload path
            $extension = $file->getClientOriginalExtension(); // getting image extension
            $fileName = rand(11111,99999).'.'.$extension; // renameing image

            $request['photo'] = $fileName;
            $request['image_path'] = $destinationPath;

            $file->move($destinationPath, $fileName); // uploading file to given path

            $quiz = Quiz::create($request->all())


        }else{
            \Session::flash('flash_message_delete','Please select files to upload.');
            return redirect()->back();
        }

它给了我FileNotFoundException in File.php line 37:The file "" does not exist。这一天工作得很好,发生了什么事情......我试着互换安排,如:

$destinationPath = 'images/quizzes/'; // upload path
            $extension = $file->getClientOriginalExtension(); // getting image extension
            $fileName = rand(11111,99999).'.'.$extension; // renameing image

            $request['photo'] = $fileName;
            $request['image_path'] = $destinationPath;

            $quiz = Quiz::create($request->all());

            $file->move($destinationPath, $fileName); // uploading file to given path

我不会有这样的错误,并且它保存到数据库,问题是photo field而不是$filename已插入的/tmp/somestrings

0 个答案:

没有答案