I want to allow multiple files upload, so I did this in my view:
{{ Form::file('files[]', array('multiple'=>true)); }}
it works, but I can't validate it. For testing purposes I've created this rule:
'files' => 'required|mimes:png,jpg,jpeg'
but it doesn't work, it always says the mime type is incorrect, I also tried it with png. Can anyone help me please? I also tried to remove the [] from the file input name. Could be the problem that laravel doesn't support multiple files at validation?
Thanks
image/png,image/jpeg... So you're probably specifying wrong MIME types.required|imagerather than specifying the mime types of images. (FWIW one of my team has definitely had issues in the past using themimesrule as you are where usingimagefixed it.) Also there is a validation rulearraythat ensures the value is an array. However, I don't know if you can then set rule against the actual elements of the array. The documentation is pretty useless here.'files' => 'required|mimes:image/jpg,image/jpeg|max:20000'but it still not work.filesvalidates againstarraythen, if so, iterate over all files and validate each one individually againstrequired|image. Then somehow bundle up all the validation errors into one MessageBag to send to the redirect if there's an error.