我在组合"normal“表单和dropzone时遇到了问题。我有一个带有文本输入、文件输入和dropzone部分的表单。我要把所有的东西都立刻发出去。所以我手动创建了dropzone字段,禁用了dropzone的autoProcessQueue
功能,并绑定到提交按钮的onClick
。
<form action="/Exhibits/Create" enctype="multipart/form-data" id="newExhibitForm" method="post">
<input id="Exhibit_Name" name="Exhibit.Name" type="text"
<input id="Exhibit_Description" name="Exhibit.Description" type="text">
<input id="ModelFile" name="ModelFile" type="file">
<input id="TextureFile" name="TextureFile" type="file">
<div id="dropzonePreview" class="dropzone-previews form-control dz-clickable">
<div class="dz-message">Drag&drop</div>
</div>
<input type="submit" value="Create" class="btn btn-default">
</form>
JS部分:
var photoDropzone = new Dropzone("#newExhibitForm", {
url: $('#newExhibitForm').attr("action"),
autoProcessQueue: false,
uploadMultiple: true,
parallelUploads: 10,
maxFiles: 10,
previewsContainer: '#dropzonePreview',
clickable: '#dropzonePreview',
// The setting up of the dropzone
init: function () {
var myDropzone = this;
var submitButton = document.querySelector('input[type=submit]');
myDropzone = this; // closure
submitButton.addEventListener("click", function (e) {
e.preventDefault();
e.stopPropagation();
if (myDropzone.getQueuedFiles().length === 0) {
$('#newExhibitForm').submit();
}
else {
myDropzone.processQueue();
}
});
}
});
当我通过单击submit按钮提交表单时,在服务器端函数中有dropzone文件、文本输入,但不发送文件输入。
有没有办法让它像我一开始描述的那样工作?
致以敬意,
康拉德
发布于 2015-10-12 20:35:39
很抱歉,现在每个文件都是单独上传的。因此,您需要将这些文件单独存储在您的服务器上,然后当dropzone发出complete
事件时,您将发送其余的输入域。
https://stackoverflow.com/questions/27991890
复制相似问题