D
D
dfgdfgdfgdfgfg2019-12-17 12:03:18
Laravel
dfgdfgdfgdfgfg, 2019-12-17 12:03:18

Why doesn't image validation work?

5df8996c3799f618555966.png

$this->validate($request, [
            'description' => 'required|min:20|max:3000',
            'images' => 'mimes:png',
        ]);

<div class="form-group">
                        <label for="images">Скриншоты</label>
                        <input type="file" multiple class="form-control-file {{($errors->has('images') ? 'error-border' : '')}}" name="images[]" id="images">
                        @if ($errors->has('images'))
                            <span class="help-block text-danger">
                                <strong>{{ $errors->first('images') }}</strong>
                            </span>
                        @endif
                    </div>

I upload a png image and...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Kovalchuk, 2019-12-28
@mamut

You have an array and it is not a picture,
you need to check the array element

$this->validate($request, [
    'description' => 'required|min:20|max:3000',
    'images.*' => 'mimes:png',
]);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question