How to get Dropzone.js to upload files only when a submit button is clicked?

后端 未结 2 653
一向
一向 2020-12-15 18:12

for the past few days I\'ve been trying to implement Dropzone into my form, but so far I had no luck figuring out how to make it upload and process the images only when the

相关标签:
2条回答
  • 2020-12-15 18:41
    <script>
    $(document).ready(function () {
        Dropzone.options.dropzoneForm = {
            autoProcessQueue: false
        };
    });
    
    function processEvent() { // call this to trigger the upload
        $('#dropzoneForm').get(0).dropzone.processQueue();
    }
    </script>
    
    <form action="/your-post-url-here" method="post" enctype="multipart/form-data" class="dropzone" id="dropzoneForm"></form>
    
    0 讨论(0)
  • 2020-12-15 18:54

    You can supply your own url to upload the file. Currently I am just setting it as 'someurl'

    Dropzone.autoDiscover = false;
    jQuery(document).ready(function() {
      var myDropzone = new Dropzone("#myId", { 
        url: 'someurl',
        autoProcessQueue:false
      });
    
      $('#add').on('click',function(e){
        e.preventDefault();
        myDropzone.processQueue();  
      });   
    });
    
    0 讨论(0)
提交回复
热议问题