我在 IE 中使用 Dojo 1.6 dojox.form.Uploader。这使用 dojox.form.uploader.plugins.Flash 插件进行上传。在 Firefox 中,使用 HTML5,我可以通过调用以下方式提交其他表单数据以及上传:
uploaderDijit.upload({paramName:"paramValue"});
但是在 IE 中,Flash 版本的上传函数不带 formData 参数。有什么方法可以使用 Flash 插件提交其他数据以及文件上传?
这是我的示例代码:
dojo.require("dojox.form.Uploader");
dojo.require("dojox.form.uploader.FileList");
dojo.require("dojox.form.uploader.plugins.Flash");
function doUpload(){
dijit.byId("uploader").upload({param: "paramValue"});
}
function onload(){
// create uploader & file list dijits
var uploaderDijit = new dojox.form.Uploader({
id: "uploader",
url: "MyApp/MyServlet",
multiple: true
});
var fileListDijit = new dojox.form.uploader.FileList({uploader:uploaderDijit});
// insert dijits into html
var formNode = dojo.byId("multiUploadForm");
var uploaderDiv = document.createElement("div");
formNode.appendChild(uploaderDiv);
uploaderDiv.appendChild(uploaderDijit.domNode);
uploaderDiv.appendChild(fileListDijit.domNode);
}
dojo.addOnLoad(onload);
和:
<form id="multiUploadForm" method="post" enctype="multipart/form-data" encoding="multipart/form-data"></form>
<button onclick="javascript:doUpload();">Upload</button>
我尝试在表单中添加一个输入节点:
<form id="multiUploadForm" method="post" enctype="multipart/form-data" encoding="multipart/form-data">
<input type="hidden" name="param" value="paramValue"/>
</form>
而且我还尝试将参数附加到 url,但没有骰子:
var uploaderDijit = new dojox.form.Uploader({
id: "uploader",
url: "MyApp/MyServlet?param=paramValue",
multiple: true
});