【发布时间】:2015-07-27 22:30:43
【问题描述】:
我试图解决这个问题,但我不能。 将文件上传到 FireFox 时,我无法上传, 但是文件会上传到 Opera 中。 在 Dropzone.js 中,我使用 bootstrap 和 jquery 作为库。
在我看来,问题在于 addEventListener? 带有萤火虫的示例视频:enter link description here
片段:
Dropzone.options.myDropzone = {
// Prevents Dropzone from uploading dropped files immediately
autoProcessQueue: false,
parallelUploads: 10,
thumbnailWidth: 120,
thumbnailHeight: 120,
init: function() {
var submitButton = document.querySelector("#submit-all");
var myDropzone = this;
submitButton.addEventListener("click", function() {
myDropzone.processQueue(); // Tell Dropzone to process all queued files.
});
this.on("addedfile", function(file) {
// Create the remove button
var removeButton = Dropzone.createElement("<button class='btn btn-xs btn-warning'>Remove file</button>");
// Listen to the click event
removeButton.addEventListener("click", function(e) {
// Make sure the button click doesn't submit the form:
e.preventDefault();
e.stopPropagation();
// Remove the file preview.
myDropzone.removeFile(file);
// // If you want to the delete the file on the server as well,
// // you can do the AJAX request here.
});
// Add the button to the file preview element.
file.previewElement.appendChild(removeButton);
});
} //dropzone init
}; //dropzone options
<script src="https://raw.githubusercontent.com/enyo/dropzone/master/dist/dropzone.js"></script>
<form action="upload/do_upload" class="dropzone" id="my-dropzone"></form>
<button type="button" class="btn btn-primary"><span id="submit-all">Submit all files</span></button>
<button type="button" class="btn btn-default"><a href="upload">Reset</a></button>
【问题讨论】:
标签: dropzone.js