dojo.io.iframe.send文件上传在IE8中发送GET请求

时间:2011-10-25 20:20:59

标签: file-upload internet-explorer-8 dojo xmlhttprequest

我正在使用dojo.io.iframe.send进行xhr文件上传,并且除了IE 8之外,它在所有浏览器中都能正常工作.IE8发送GET请求而不是多部分POST。这是我的代码:

dojo.io.iframe.send({
            form: this.logoForm.domNode,
            handleAs: "json",
            method: "POST",
            url: '/backend/design/uploadLogo',
            load: dojo.hitch(this, function(response) {
                if (response.error) {
                    errorFunc(response);
                } else {
                    this.submitStatusLogo.innerHTML = "Your logo has been successfully uploaded.";
                    this.logoButton.hideIndicator();
                    dojo.addClass(this.submitStatusLogo, "success");
                    if (response.logoPath) {
                        this.productLogo.innerHTML = '<img src="'+response.logoPath+'" alt="" />';
                    }
                }
            }),
            error: errorFunc
        });

this.logoForm.domNode是:

<form dojoAttachPoint="logoForm" dojoType="dijit.form.Form" enctype="multipart/form-data" class="designLayoutForm">
    <div class="uploadedImage" dojoAttachPoint="productLogo"></div>
    <h2>Logo
        <span dojoType="sc2.common.TinyHelp" title="Logo">
            Upload a product logo that will be shown in the top left of the demo page.<br />
            If the logo is higher than 80 pixels, it will be resized to a height of 80px. <br />
            <br />
            <i>Supported file types are: png, jpg, gif, bmp.</i>
        </span>
    </h2>
    <p>
        <input type="hidden" dojoAttachPoint="logoForm_product" name="product" value="" />
        <input type="hidden" dojoAttachPoint="logoForm_XSessionVerify" name="X-Session-Verify" value="" />
        <input type="file" name="file" dojoAttachPoint="logoInput" />
    </p>
    <p dojoAttachPoint="submitStatusLogo" class="submitStatus"></p>
    <p>
        <input dojoType="sc2.form.IndicatorButton" dojoAttachPoint="logoButton" label="Upload">
    </p>
</form>

我做错了什么?

1 个答案:

答案 0 :(得分:5)

好的,我解决了它,将form =“POST”添加到表单元素就可以了。显然指定方法:发送参数中的“POST”对于IE8来说是不够的。非常感谢你的时间