【发布时间】:2015-01-14 21:37:35
【问题描述】:
我想将 dropzonejs 添加到具有其他元素的表单中。我找到了这个示例并按照说明进行操作,不幸的是整个 from 变成了 dropzonejs 放置区:https://github.com/enyo/dropzone/wiki/Combine-normal-form-with-Dropzone
这是我的代码:
<form action="/Post/Edit" class="dropzone" enctype="multipart/form-data" method="post">
<div class="form-group">
<label for="PostAddress_AddressLineOne">Address Line One</label>
<input class="form-control" id="PostAddress_AddressLineOne" name="PostAddress.AddressLineOne" type="text" value="" />
</div>
<div class="dropzone-previews"></div>
<div class="fallback">
<!-- this is the fallback if JS isn't working -->
<input name="file" type="file" multiple />
</div>
<script type="text/javascript">
Dropzone.options.dropzoneJsForm = {
//prevents Dropzone from uploading dropped files immediately
autoProcessQueue: false,
uploadMultiple: true,
parallelUploads: 25,
maxFiles: 25,
addRemoveLinks: true,
previewsContainer: ".dropzone-previews",
// The setting up of the dropzone
init: function() {
var myDropzone = this;
// Here's the change from enyo's tutorial...
$("#submit-all").click(function(e) {
e.preventDefault();
e.stopPropagation();
myDropzone.processQueue();
});
}
};
</script>
我也关注了以下帖子,整个 from 仍然是一个放置区: Integrating dropzone.js into existing html form with other fields
我必须在表单中有一个 from with 吗?
谢谢
【问题讨论】:
-
嵌套的 FORM 元素通常无效。请参阅stackoverflow.com/questions/555928/… /// BTW 是“dropzone”类将您的整个表单激活为 dz。
标签: javascript file upload