0
votes

I am using dropzone.js to upload files. Whenever $validation->fails()==true, my response::make breaks with the following error:

"Call to a member function first() on a non-object","file"

Code: public function uploadPhotosAction() { if(Input::file('file')){ $input = Input::all(); $rules = array( 'file' => 'mimes:jpeg,bmp,png|max:5120|min:265', //Only allow files of the type "image" no smaller than 256 kb and no larger than 5 mb ); $validation = Validator::make($input, $rules);

      if ($validation->fails())
      {
        return Response::make($validation->errors->first('file'), 400);
      }
2

2 Answers

0
votes

try using $input = Input::file('file') instead of $input=Input::all()

I recomend you to read the docs http://laravel.com/docs/requests#files

0
votes

It's a method not property, so simply this:

return Response::make($validation->errors()->first('file'), 400);