Laravel 5 - DropzoneJS: Request object is empty -


i've decided upgrade website laravel 4.3 laravel 5.1 , i'm facing strange problem.

i'm trying upload pictures using dropzonejs library. i'm telling library: "before sending pictures /pictures/store (with ajax post method), adds album_id parameter request".

this part working in picturecontroller, store action taking request object remains empty instead of containing inputs , many other things.

view:

{!! form::open(['url' => '/pictures/store', 'class' => 'dropzone', 'id' => 'myawesomedropzone']) !!}     {!! form::hidden('album_id', $album->id) !!} // gives correct value here {!! form::close() !!} 

js:

var token = $('meta[name="csrf-token"]').attr('content');  dropzone.options.myawesomedropzone = {     paramname : 'file',     maxfilesize : 8, // mo     acceptedfiles : 'image/*',     headers : {         'x-csrf-token' : token     },     sending : function(file, xhr, formdata) {         formdata.append('album_id', $('form input[name=album_id]').val()); // still correct value here     },     success : function(file, response) {         console.log(response); // display request object (see controller)     },     error : function(file, error) {         console.error(error);     } } 

controller:

<?php  namespace app\http\controllers;  use illuminate\http\request;  use app\http\requests; use app\http\controllers\controller;  class picturecontroller extends controller {      public function store(request $request) {          return response()->json(['request' => $request]); // returns request object      }  } 

here request object:

request object

not containing anything... , ajax request:

-----------------------------98052356720717 content-disposition: form-data; name="album_id"  1 -----------------------------98052356720717 content-disposition: form-data; name="_token"  it1dqqixuiljgwgjwx5uvxe1qep7tsc1uovglxd2 

well, found solution i'm pretty sure isn't best one.

in picturecontroller instead of getting album_id parameter this:

$request->input('album_id') 

i used input facade (laravel 4's style):

input::get('album_id') 

and don't know why, works ! if have better solution, sure pick answer best one. meanwhile, mine best :d


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -