2

I have been trying to implement a dropzone file upload module with Laravel 5.

The problem is that when a file is uploaded dropzone sends the full request to the file upload controller, however, the controller does not get any data.

What am I missing? I have included the code I'm using. Thanks in advance for your time/help.

The view

{!! Form::open( array( 'url' => 'admin/file/upload', "id"=>"file-upload-modal", 'class'=>"dropzone" ) ) !!}
{!! Form::close() !!}

Controller

public function upload(FileUploadRequest $request){
        //addeed this line for testing. //returns request array with an empty data set. 
        return response()->json($request);
        if($request->hasFile('file')){
            $request->file('file')->move('images');
        }
    }

It returns a 200 status code and dropzone thinks the file gets uploaded. However the response is actually an empty data set response:

{"attributes":{},"request":{},"query":{},"server":{},"files":{},"cookies":{},"headers":{}}
menjaraz
  • 7,551
  • 4
  • 41
  • 81
  • 4
    Turned out that there was no problem in the code and all the confusion was trying to analyse the response. The response somehow empties the files array and hence the empty data set. It actually gets uploaded and if you correctly assign the path and the file name in the move function [ $request->file('file')->move('images', 'filename') ] everything works fine. If only the directory is specified then the moved file has the temp name. I hope this info helps an exhausted coder who's chasing a shadow :) – Wheel Barrow Feb 20 '15 at 09:46
  • 1
    You can post your answer and accept it later. Please do! – menjaraz Apr 20 '15 at 10:09

0 Answers0