lundi 3 juillet 2017

laravel 5.4 file validation don't break on single mismatch

I'm building a file upload in which the user can upload multiple files. In this system, only images are allowed, the images should meet certain requirements before they're allowed in the system. So I have a bit of validation on that form field by doing this:

$this->validate( $request, [
            'files.*'      => 'required|mimes:jpg,jpeg,gif,png,tiff,psd,bmp|customValidator'
        ] );

What I want is that the validation doesn't break when a single file doesn't match. It should add all files except the files that don't match.

For example: When I upload 19 images and one pdf, all 19 images should be added to the system and I should be notified (on screen) that my pdf was rejected. Is that possible within this validation or should I do something different?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire