这是this question的延续,在对这里给出的建议取得了一些进展之后。未使用Dropzone表单的POST数据传输的文件输入数据
我有一个Typo3的形式,大约这个加价:
<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
这是上传文件时的POST数据:
------WebKitFormBoundaryrEmFA8jYcHY56WAB
Content-Disposition: form-data; name="tx_applicationformgeneral[form][files][]"; filename="DSC01413_01.JPG"
Content-Type: image/jpeg
我把表格变成了Dr opzone加入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();
});
}
};
这似乎工作,以初始化一个悬浮窗:我可以将文件拖放到窗体和预览出现。但是当我点击“提交”时,根本没有发送文件上传字段数据。 POST标题中没有标题为“tx_applicationformgeneral [form] [files] []”或任何变体。 POST数据完全没有,尽管所有其他字段都包含在内。这仍然如此,如果我重新命名PARAMNAME到
paramName: "tx_applicationformgeneral[form][files]"
因为没有收到该文件的上传,当至少一个空场的预期,我得到后端并没有什么大的丑Typo3的错误得到处理。
我想这是Dropzone插入POST数据的问题。如果问题在于paramName错误,那么数据将在POST数据中以不正确的名称可见,我仍然会看到后端错误。相反,根本没有文件上传数据。
任何人都可以提出可能会发生什么?
UPDATE
引起了我的错误之一:我被定位按钮[类型= “提交”],当我的形式使用输入[类型= “提交”]。尚未修正,但已经发展到新的有趣的失败&。