How to validate upload of multiple files in laravel

0

I have the following validation rule in the controller:

 $validator = Validator::make($request->all(), [
        'nome' => 'required|max:255',
        'valor' => 'required|numeric|min: 0',
        'imagens' => 'required|mimes:jpeg,jpg,png|max:1000',
        'descricao' => 'max: 255',
        'finalidade' => 'max: 255',
        'area' => 'required|numeric|min:0',
        'quartos' => 'required|numeric|min:0',
        'banheiros' => 'required|numeric|min:0',
        'garagens' => 'required|numeric|min:0',
        'suites' => 'required|numeric|min:0',
        'imagens.*' => 'required|mimes: jpeg,jpg,bmp,png'
    ]);

With an input file as follows:

<input type="file" name="imagens[]" multiple value="{{ old('imagens') }}" id="" class="form-control">

Even when I upload 2 .jpg files the validation fails, saying that the format has to be jpg.

I think the validation should be done file by file. Can anyone do this?

    
asked by anonymous 22.12.2017 / 17:33

0 answers