dropzone js onclick提交文件上传 [英] dropzone js onclick submit file upload

查看:253
本文介绍了dropzone js onclick提交文件上传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只需点击一下按钮即可上传所有文件。

HTML:

 < button id =submit-all>提交所有文件< / button> 
< form action =/ targetclass =dropzoneid =my-dropzone>< / form>

JS:

  Dropzone.options.myDropzone = {

//阻止Dropzone立即上传丢弃的文件
autoProcessQueue:false,

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

submitButton.addEventListener(click,function(){
myDropzone.processQueue(); //告诉Dropzone处理所有排队的文件。
});

//你可能只想在这里删除
//文件时显示提交按钮:
this.on(addedfile,function(){
//在此处显示提交按钮和/或通知用户点击它。
});

}
};

但拖放后文件上传..

  Dropzone .autoDiscover = false; 

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

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


upload all files with a single button click.
HTML:

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

JS:

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.
    });

  }
};

But the file is upload after drag and drop..

解决方案

use simple code

Dropzone.autoDiscover = false;

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

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

这篇关于dropzone js onclick提交文件上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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