我正在使用表单验证来在laravel 5.1中上传文件,
class FileUploadRequest extends Request {
public function rules() {
return ['file' => 'required', 'max:2048', 'mimes:pdf,png,jpeg,jpg'];
}
public function upload(FileUploadRequest $request) {
}
但它没有验证大小和哑剧..我有什么问题?
答案 0 :(得分:1)
尝试像这样修改规则功能
public function rules()
{
return [
'file' => 'required|mimes:pdf,png,jpeg,jpg|size:2048',
];
}