我已經按照Combine Dropzone With Normal Form教程允許Dropzone上傳&表單提交。該表格是一個申請表格,它應該與&一起使用而不添加文件。目前它僅在將一個或多個文件添加到Dropzone時起作用。我可以使用Dropzone提交表單而無需上傳任何文件嗎?
是否有一個選項可以允許Dropzone處理表單提交,即使上傳隊列爲空?
下面是如何初始化形式:
Dropzone.options.general = {
paramName: 'tx_ddapplicationform_applicationformgeneral[form][files]', // The name that will be used to transfer the file
autoProcessQueue: false,
uploadMultiple: true,
parallelUploads: 100,
maxFiles: 100,
addRemoveLinks: true,
previewsContainer: '.dropzone-previews', // we specify on which div id we must show the files
clickable: false,
// The setting up of the dropzone
init: function() {
var myDropzone = this;
console.log(myDropzone)
console.log("Dropzone init");
console.log(this.element.querySelector("input[type=submit]"))
// First change the button to actually tell Dropzone to process the queue.
this.element.querySelector("input[type=submit]").addEventListener("click", function(e) {
// Make sure that the form isn't actually being sent.
console.log("the button is clicked")
e.preventDefault();
e.stopPropagation();
myDropzone.processQueue();
console.log("after processQueue")
});
// Listen to the sendingmultiple event. In this case, it's the sendingmultiple event instead
// of the sending event because uploadMultiple is set to true.
this.on("sendingmultiple", function() {
console.log("sending multiple");
});
this.on("successmultiple", function(files, response) {
console.log("success multiple");
});
this.on("errormultiple", function(files, response) {
console.log("error multiple");
});
}
我通過dropzone.js形式去並添加console.logs,看看發生了什麼事情。成功提交(添加文件)記錄本:
processQueue dropzone.js:1301
upload multiple dropzone.js:1314
sending multiple main.jquery.js:551
after processQueue main.jquery.js:545
success multiple main.jquery.js:554
不成功的提交,無需附加的文件,記錄此:
processQueue dropzone.js:1301
after processQueue main.jquery.js:545
可能重複:[DropZonejs:提交表單沒有文件(http://stackoverflow.com/questions/20910571/dropzonejs-submit-form -without-files?rq = 1) –
你如何在服務器端接收圖像?我使用PHP和我打印$ _FILES,但它是空的。我不知道該去哪找... – Limon