T
T
toropchin2015-05-06 07:36:30
Laravel
toropchin, 2015-05-06 07:36:30

How to validate an uploaded image in Laravel 5?

I'm trying to validate the uploaded image in laravel 5.
I'm doing this:

$validator = Validator::make
            (
                ['image' => $_FILES['photos']['tmp_name']],
                ['image' => 'mimes:jpeg,jpg,bmp,png'],
                ['mimes' => 'Некоторые файлы не загружены, потому что они не являются изображениями']
            );

As a result, even the correct files do not pass validation.
Tried to pass a variable like this $_FILES['photos']. The same.
How to do it right?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey, 2015-05-07
@xelam

public function rules()
{
    return [
       'file' => 'required|mimes:jpeg'
    ];
}

laravel.com/docs/5.0/validation#form-request-validation

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question