如何向dropzone添加提交按钮

问题描述 投票:1回答:1

各位大家好我正在使用dropzone.js将图片上传到带有php的服务器,但我有点问题。

我想知道是否有任何方法禁止dropzone.js自动上传到服务器拖放图像或点击并选择图像并使用可点击的提交按钮手动将图像提交到服务器

请提供任何建议或帮助,我们将非常感谢您提供简单的代码

编辑

我仍然没有得到我的问题的答案。

说真的,我觉得这个人建造这些东西是不对的,因为这些东西在某些方面是无用的,他们是否试图告诉我,当用户上传其个人资料图片时,掉落区域会卡在那里看着他们看起来在没有提交按钮或确认消息的情况下,图片已经上传,那么他们应该继续吗?当真?

drag-and-drop dropzone.js
1个回答
1
投票

您可以在HTML表单中定义按钮,例如

<button id="submit-all">Submit all files</button>

然后添加此脚本

Dropzone.options.myDropzone = {
  // Prevents Dropzone from uploading dropped files immediately
  autoProcessQueue: false,
  acceptedFiles: ".png,.jpg,.gif,.bmp,.jpeg",
  maxFilesize: 1,
  parallelUploads: 10,
  addRemoveLinks: true,
  init: function() {
    var submitButton = document.querySelector("#submit-all")
    myDropzone = this; // closure

    submitButton.addEventListener("click", function() {
      myDropzone.processQueue(); 
      // autoProcessQueue: true// 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.
    });

  }
};

希望这能解决问题。参考qazxsw poi

© www.soinside.com 2019 - 2024. All rights reserved.