mercredi 5 décembre 2018

how to recover an input file sent with dropzone in Laravel

I have an extra input file with other fields sending with Dropzone, but i cant get the value of the input file. How can i get the value of the input and store. This is my dropzone :

 var myDropzone1 = new Dropzone("div#image-upload", { 
            url: "publicar/store",
            autoProcessQueue:false,
            parallelUploads: 100,
            uploadMultiple: true,
            maxFilesize:1,
            headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            },
            init: function(){
                myDropzone1 = this; // closure
                var btn1 = document.querySelector("#submit-all");
                btn1.addEventListener("click", function(e) {
                    e.preventDefault();
                    e.stopPropagation();

                });

                this.on("sending", function(file, xhr, data) {

                        var year = $('#year').val();
                        data.append("principal",$('#principal')[0].files[0]);


                        data.append("year", year);
                });
                this.on("success", function(file, xhr){

                     alert(file.xhr.response);

                    $('#completoMsg').css("display", "block");
                })

            }


  });

My controller to save the data and image

$files1 = $request->file('principal');


    foreach($files1 as $file1){
        /// RESIZE

        $input['imagename'] = time() . "." . $file1->getClientOriginalExtension();
        $anuncio->foto = $input['imagename'];
        $img = Image::make($file1->getRealPath());
        $img->fit(254, 190)->save($destinationPath.'/'. $input['imagename']);

    }


    $anuncio->save();



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2Pm7UkM
via IFTTT

Aucun commentaire:

Enregistrer un commentaire