Php Laravel 5“文件”&引用;不存在
我正在上传一个文件。这是我的控制器Php Laravel 5“文件”&引用;不存在,php,laravel,laravel-5,Php,Laravel,Laravel 5,我正在上传一个文件。这是我的控制器 if ($request->hasFile('photo')) { $destinationPath = 'images/quizzes/'; // upload path $extension = $file->getClientOriginalExtension(); // getting image extension $fileName = rand(11111,999
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();
}
它在File.php第37行给出了FileNotFoundException:文件“”不存在
。前几天这一切都很顺利,idk发生了什么事..我试着像这样交换安排:
$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
我不会有这样的错误,它会保存到数据库中,问题是
照片字段
而不是$filename
它插入了wierd/tmp/somestrings
。第37行的代码是什么?你上传的文件大小是多少?file.php来自laravel,我尝试上传400Kb的文件。我还注意到它在给我错误之前上传到了图片中,因为文件在那里。也许检查一下是有用的:它不能解决我的问题,这真的很好,它工作得很好,然后出现了这个错误第37行的代码是什么?你上传的文件的大小是多少?file.php来自laravel,我尝试上传400Kb的文件。我还注意到它在给我错误之前上传到了图片中,因为文件就在那里。也许检查一下这一点是有用的:它不能解决我的问题,这真的很奇怪,它工作得很好,然后出现了这个错误