mbpp's avatar
Level 3

DropzoneJs issues on images title

Hello, im implemeting dropzone in my app, but i need to insert a title, the upload works fine, but after reading about appending dynamic data to each image, i saw in dropzone tips saying: "If you want to add additional data to the file upload that has to be specific for each file, you can register for the sending event:"

So i imeplemetend, but in my case is not giving each image a title, is always giving them all the first title of the image, above i leave my code.

$('#add').on('click',function(e){ e.preventDefault(); myDropzone.processQueue(); });

   Dropzone.autoDiscover = false;
    // Dropzone class:
    var myDropzone = new Dropzone("div#myId", {
        url: "/galleries",
        autoProcessQueue:false,
        headers: {
            'X-CSRF-TOKEN': '0gm2HfBcWiCf2pqy6Dhrv1RRYVvED89Nm50NsLxX',

        }, init: function() {
            this.on("sending", function(file, xhr, formData) {
              formData.brand = document.getElementById('brand').value;
    formData.append("brand", document.getElementById('brand').value);
                console.log(formData);
            });
        },
        previewTemplate: "<div class=\"dz-preview dz-file-preview\">\n  " +
        "<div class=\"dz-image\"><img data-dz-thumbnail /></div>\n " +
        "<input type=\"text\" id=\"brand\" data-dz-brand name=\"dz-brand\">\n " +
                "<input type=\"text\" id=\"url\" name=\"dz-url\">\n " +
   " ..."
             }



   );
0 likes
0 replies

Please or to participate in this conversation.