5
votes

I am using Laravel 5 Validator for validating avatars, my rules look like this:

$validator = Validator::make(
    Request::all(),
    [
        'avatar' => 'required|image|max:1000'
    ]
);

I am trying to upload files and it always says "no file choosen". If I remove the required rule, then it works, even the max:1000 rule work.

1
Can you do a dd(Request::get('avatar')) before calling the make method? Are you trying to validate a form? - Jeremy D
Can supply the code for your form please - Chris Townsend
Does your form has multipart/form-data so it can work properly with files? - Björn
Did you find an answer to this? - alaboudi
Yes, i did, you need to first type image and then all the other stuff. - Tadeáš Jílek

1 Answers

29
votes

make sure that form accept files,

Form::open(array('url' => 'foo/bar', 'files' => true))

or

<form action="foo/bar" enctype="multipart/form-data">