Javascript 文件输入数据未与Dropzone表单的POST数据一起传输
这是在对那里提出的建议取得一些进展之后的继续 我有一个打字3表格,大约有这个标记:Javascript 文件输入数据未与Dropzone表单的POST数据一起传输,javascript,forms,dropzone.js,Javascript,Forms,Dropzone.js,这是在对那里提出的建议取得一些进展之后的继续 我有一个打字3表格,大约有这个标记: <form enctype="multipart/form-data" method="post" name="form" id="general" action="index.php?id=328"> <ul class="inline-textbox"> <li> <input type="text" id="first_
<form enctype="multipart/form-data" method="post" name="form" id="general" action="index.php?id=328">
<ul class="inline-textbox">
<li>
<input type="text" id="first_name" name="tx_applicationformgeneral[form][name]" value="" placeholder="Name *">
</li>
</ul>
<div class="dropzone-previews">
</div>
<input class="button" type="submit" name="tx_applicationformgeneral[mySubmit]" value="Submit">
</form>
这是上传文件后的POST数据:
------WebKitFormBoundarySq0AkJrSAe1kmAOu
Content-Disposition: form-data; name="tx_applicationformgeneral[form][files][]"; filename=""
Content-Type: application/octet-stream
------WebKitFormBoundaryrEmFA8jYcHY56WAB
Content-Disposition: form-data; name="tx_applicationformgeneral[form][files][]"; filename="DSC01413_01.JPG"
Content-Type: image/jpeg
通过向表单元素添加classDropzone
,并传递以下初始化选项,我已将表单转换为Dropzone:
Dropzone.options.general = {
paramName: "tx_applicationformgeneral[form][files][]", // The name that will be used to transfer the file
autoProcessQueue: false,
uploadMultiple: true,
parallelUploads: 100,
maxFiles: 100,
addRemoveLinks: true,
// The setting up of the dropzone
init: function() {
var myDropzone = this;
console.log("Dropzone init");
// First change the button to actually tell Dropzone to process the queue.
this.element.querySelector("button[type=submit]").addEventListener("click", function(e) {
// Make sure that the form isn't actually being sent.
e.preventDefault();
e.stopPropagation();
myDropzone.processQueue();
});
}
};
这似乎可以用于初始化Dropzone:我可以将文件拖放到表单上,并显示预览。但当我单击“提交”时,根本不会发送任何文件上载字段数据。标题为“tx_applicationformgeneral[form][files][]”或任何变体的帖子标题中没有任何内容。POST数据中完全没有该字段,尽管所有其他字段通常都包含在内。如果我将paramName重新命名为
paramName: "tx_applicationformgeneral[form][files]"
因为上传文件时没有收到任何信息,所以当至少需要一个空字段时,我在后端收到一个非常难看的Typo3错误,什么都没有得到处理
我想Dropzone在POST数据中插入此字段可能有问题。如果问题是paramName错误,我会预料到数据将以错误的名称在POST数据中可见,并且我仍然会看到后端错误。相反,根本没有文件上传数据
有人能提出可能发生的事情吗
更新
捕获到我的一个错误:当我的表单使用输入[type=“submit”]时,我正在锁定按钮[type=“submit”]。尚未修复,但出现了新的有趣的故障。由于我对提交按钮使用了错误的选择器,因此未触发Dropzone队列处理。当我的表单使用输入[type=“submit”]时,我的目标是按钮[type=“submit”]