如果que上至少只有10个文件,我如何设置dropzone上传



如果que上至少只有10个文件,我如何设置dropzone上传?

我已经将autoProcessQueue设置为false,这样当单击提交按钮时,将运行一个函数来检查qeed文件。如果它们小于或大于10,则不会进行上传。

我该如何做到这一点?请协助。

我在谷歌上到处找,但似乎找不到答案。请协助!

这是我的密码。。

<html>
<head>
<title></title>
<script src="ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">   </script>
<link href="css/basic.css" rel="stylesheet" type="text/css" />
</head>

<body>
<form role= "form"></form>
<button id="submit-all">Submit all files</button>
</body>
<script>
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.

});
myDropzone.on("maxfilesexceeded", function(file) { this.removeFile(file); });

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

您可以使用dropzone:中的方法getQueuedFiles()在init函数内完成此操作

Dropzone.autoDiscover = false;
Dropzone.options.myDropzone = {
    autoProcessQueue: false,
    init: function () {
        var submitButton = document.querySelector("#submit-all");
        myDropzone = this;
        submitButton.addEventListener("click", function () {
            if (myDropzone.getQueuedFiles().length >= 10) { 
                myDropzone.processQueue();
            }
            else {
                alert("Not enough files!");
            }
        });
    }
};
var myDropzone = new Dropzone('form#my-dropzone');

相关内容

最新更新