dropzone js onclick提交文件上传

新手上路,请多包涵

单击一次按钮即可上传所有文件。

HTML:

 <button id="submit-all">Submit all files</button>
<form action="/target" class="dropzone" id="my-dropzone"></form>

记者:

 Dropzone.options.myDropzone = {

  // Prevents Dropzone from uploading dropped files immediately
  autoProcessQueue: false,

  init: function() {
    var submitButton = document.querySelector("#submit-all")
        myDropzone = this; // closure

    submitButton.addEventListener("click", function() {
      myDropzone.processQueue(); // Tell Dropzone to process all queued files.
    });

    // You might want to show the submit button only when
    // files are dropped here:
    this.on("addedfile", function() {
      // Show submit button here and/or inform user to click it.
    });

  }
};

但是文件是拖放后上传的..

原文由 Steve Bals 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 450
1 个回答

使用简单的代码

Dropzone.autoDiscover = false;

var myDropzone = new Dropzone(element, {
  url: "/upload.php",
  autoProcessQueue: false,
});

$('#imgsubbutt').click(function(){
  myDropzone.processQueue();
});

原文由 Behnam 发布,翻译遵循 CC BY-SA 3.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
logo
Stack Overflow 翻译
子站问答
访问
宣传栏