Dropzone.js

Hi!

I’m trying to implement use kato\DropZone. I have managed to upload the files without truble but I need to send some data with the image im uploading.

I have the widget set like this:




<?= DropZone::widget([

                            'options' => [

                                'url'=>'index.php?r=evento%2Fcreate',

                                'maxFilesize' => '1',

                                'maxFiles' => 1,

                                'dictDefaultMessage' => '<img src=eventos/no_image.jpg class="dz-image" alt="logo" width="100%">',

                                'clickable' => '#myDropzone',

                                //'addRemoveLinks' => 'false',

                                'autoProcessQueue' => false,

                                //'autoDiscover' => false,

                                //'thumbnailWidth' => '500',

                                //'thumbnailHeight' => '500',

                                //'previewTemplate' => '<div class="image-responsive"></div>',


                            ],

                            'clientEvents' => [

                                'sending' =>    'function(file, xhr, formData) {

                                                    form = $("#crearEvento");

                                                  //append the data from the original form to the dropzone widget

                                                    formData.append(form);

                                                }',

                                'success' => '  function(file, response){

                                                    console.log("la respuesta del dropzone es: "+response);

                                                }',

                                'complete' => 'function(file){console.log(file)}',

                                'removedfile' => 'function(file){console.log(file.name + " is removed")}',

                                'maxfilesreached' => '  function(file){

                                                            $(".dz-default").remove();

                                                        }',

                                'maxfilesexceeded' => ' function(file){

                                                            this.removeAllFiles();

                                                            this.addFile(file);

                                                        }', 

                                //'autosdaDiscover' => false,

                            ],

                        ]);

                    ?>



And the form gets submited with ajax using




$('#crearEvento').on('beforeSubmit', function(e){

       myDropzone.processQueue();

});



This way i’m trying to submit everything together but the only POST data im getting in the controller action is the _csrf token, all the other data from the form seams to be lost.

Anything i’m missing?¿