多个dropzone.js-单页 [英] Multiple dropzone.js - single page

查看:70
本文介绍了多个dropzone.js-单页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不是在单个dropzone元素上上传多个文件,而是可以在单个页面上包含多个dropzone元素吗?

Rather than having multiple file uploads on a single dropzone element - is it possible to have multiple dropzone elements on a single page?

当有多个元素,每个元素都初始化了自己的dropzone时,似乎在选择对话框之后甚至没有触发dropzone

It seems dropzone isn't even triggering after the select dialog when there are multiple elements,each with their own dropzone initialized

推荐答案

使用dropzone的典型方法是通过创建一个带有dropzone类的表单元素:

The typical way of using dropzone is by creating a form element with the class dropzone:

<form action="/file-upload"
      class="dropzone"
      id="my-awesome-dropzone"></form>

就是这样. Dropzone会找到所有带有dropzone类的表单元素,并自动将其附加到其上,然后将放置在其中的文件上传到指定的action属性.然后,您可以像这样访问dropzone元素:

That's it. Dropzone will find all form elements with the class dropzone, automatically attach itself to it, and upload files dropped into it to the specified action attribute. You can then access the dropzone element like so:

// "myAwesomeDropzone" is the camelized version of the HTML element's ID
Dropzone.options.myAwesomeDropzone = {
  paramName: "file", // The name that will be used to transfer the file
  maxFilesize: 2, // MB
  accept: function(file, done) {
    if (file.name == "justinbieber.jpg") {
      done("Naha, you don't.");
    }
    else { done(); }
  }
};

这篇关于多个dropzone.js-单页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆