I am using form validation to upload file in 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) {
}
But it is not validating both size and mime.. what is wrong with me?
Try modifying the rules function like this
public function rules()
{
return [
'file' => 'required|mimes:pdf,png,jpeg,jpg|size:2048',
];
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.