Laravel 5.5 Validate multiple file upload

天大地大妈咪最大 提交于 2019-12-04 17:32:34

You can validate your file following way.

$input_data = $request->all();

$validator = Validator::make(
$input_data, [
'image_file.*' => 'required|file|mimes:xlsx,xls,csv,jpg,jpeg,png,bmp,doc,docx,pdf,tif,tiff'
],[
    'image_file.*.required' => 'Please upload an image',
    'image_file.*.mimes' => 'Only xlsx,xls,csv,jpg,jpeg,png,bmp,doc,docx,pdf,tif,tiff images are allowed',

]
);

if ($validator->fails()) {
    $messages = $validator->messages();
    return Redirect::to('/')->with('message', 'Your erorr message');
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!