use dropzone without auto uploading

后端 未结 1 2018
刺人心
刺人心 2021-01-12 20:19

I want to use drop zone drag and drop multiple file up-loader. the thing it does is automatically uploads file to server using Ajax. But I want it to perform another functio

1条回答
  •  感情败类
    2021-01-12 20:59

    You should set autoProcessQueue parameter to false.

    You can do this way :

    HTML - Add button

    JavaScript - set autoProcessQueue to false, add click event on the button ID and fire the processQueue event to upload the file

    Dropzone.options.your_form_id = {
        autoProcessQueue: false,
    
        init: function (e) {
    
            var myDropzone = this;
    
            $('#btn_upload').on("click", function() {
                myDropzone.processQueue(); // Tell Dropzone to process all queued files.
            });
    
            // Event to send your custom data to your server
            myDropzone.on("sending", function(file, xhr, data) {
    
                // First param is the variable name used server side
                // Second param is the value, you can add what you what
                // Here I added an input value
                data.append("your_variable", $('#your_input').val());
            });
    
        }
    };
    

    0 讨论(0)
提交回复
热议问题