小文件被上传,但在Laravel中没有大文件
我在控制器中有此操作
public function upload() {
// getting all of the post data
$file = array('image' => Input::file('image'));
//return $file;
// setting up rules
$rules = array('image' => 'required'); //mimes:jpeg,bmp,png and for max size max:10000
// doing the validation, passing post data, rules and the messages
$validator = Validator::make($file, $rules);
if ($validator->fails()) {
// send back to the page with the input data and errors
// return Redirect::to('upload')->withInput()->withErrors($validator);
return "error validation";
}
else {
// checking file is valid.
if (Input::file('image')->isValid()) {
$destinationPath = 'myuploads'; // upload path
$extension = Input::file('image')->getClientOriginalExtension(); // getting image extension
$fileName = Input::file('image')->getClientOriginalName();
// $fileName = rand(11111,99999).'.'.$extension; // renameing image
Input::file('image')->move($destinationPath, $fileName); // uploading file to given path
return "upload success";
}
else {
// sending back with error message.
Session::flash('error', 'uploaded file is not valid');
return "error";
}
}
}
它适用于2MB等小文件大小,但不适用于4MB文件大小。对于4MB或更多,它在验证中会出现错误。在上面的代码中有这个代码
if ($validator->fails()) {
return "error validation";
}
它给出了这个自定义错误 。我已经在最大上传限制和发布限制配置php.ini。error validation