How to validate uploading multiple files in the Windows

Asked

Viewed 522 times

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 files . jpg the validation fails, saying the format has to be jpg.

I think the validation should be done file by file. Someone can do this?

  • Have you tried removing this line 'imagens' => 'required|mimes:jpeg,jpg,png|max:1000', and leaving only this 'imagens.*' => 'required|mimes:jpeg,jpg,bmp,png' ?

  • Yes. Actually I hadn’t seen that it was duplicated. Vi now, but even removing, individually points out that the file 1 and 2 must have jpg format. Strange, because they are in this format...

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.