我遇到这种形式的合并问题。当前,因为我在表单内的dropzone div已被注释掉,所以底部表单dropzone照常工作。
我的意图是我想将此表格合并到我的初始表格中。
但是,我无法在选项中添加网址。当我在选项中输入网址时,会出现以下错误:
未捕获的错误:未提供URL。 在新的Dropzone(dropzone.js:1066) 在dropzone.js:2968 在Function.Dropzone.discover(dropzone.js:2974) 在Dropzone._autoDiscoverFunction(dropzone.js:3516) 在HTMLDocument.init(dropzone.js:3484)
我试图将Dropzone.autoDiscover = false放在$(document).ready代码之前,但这仅消除了no url问题,并且上载仍然无效
这是表单代码:
<script>
Dropzone.options.dropzone = {
autoProcessQueue: false,
addRemoveLinks: true,
maxFiles: 1,
uploadMultiple: false,
parallelUploads: 1,
acceptedFiles: ".csv",
init: function () {
var submitButton = document.querySelector("#submit");
var token = $('input[name="__RequestVerificationToken"]').val();
var wrapperThis = this;
submitButton.addEventListener("click", function (e) {
wrapperThis.processQueue();
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
return false;
});
this.on('sending', function (data, xhr, formData) {
formData.append("__RequestVerificationToken", token);
});;
this.on('error', function (file, message) {
wrapperThis.disable();
});
this.on('success', function (file, message) {
$(".dz-remove").hide();
wrapperThis.disable();
$(document).off("submit");
});
}
};
</script>
<div class="col-sm-12">
@using (Html.BeginForm(null, null, FormMethod.Post, new { @action = "/", enctype = "multipart/form-data", id = "form" }))
{
@Html.AntiForgeryToken()
<div class="row">
<div class="col-sm-12">
<div class="form-group">
@Html.LabelFor(m => m.MessageContent)
@Html.TextAreaFor(m => m.MessageContent, new { @class = "form-control col-sm-12", @readonly = true })
@Html.ValidationMessageFor(m => m.MessageContent)
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<h5>Message Content Data Upload</h5>
<p>This uploader only takes csv files. You can generate a file containing the relevant fields in the <a asp-area="Templates" asp-controller="Messages" asp-action="Index">Templates</a> page.</p>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label>Data</label>
@*<div id="dropzone" name="Files" class="dropzone form-group"></div>*@
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label>Status</label>
<textarea rows="10" class="form-control col-sm-12" disabled id="UploadActivity"></textarea>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<hr />
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="form-group">
<div class="clearfix">
<div class="pull-right">
<button type="submit" id="submit" class="btn btn-primary">Send</button>
@Html.ActionLink("Cancel", "Index", @ViewContext.RouteData.Values["controller"].ToString(), new { }, new { @class = "btn btn-outline-secondary" })
</div>
</div>
</div>
</div>
</div>
}
</div>
<form action="/" method="post" class="dropzone" id="dropzone"></form>