FORMDATA不工作在Internet Explorer? [英] FormData not working in Internet Explorer?

查看:115
本文介绍了FORMDATA不工作在Internet Explorer?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

    function uploadPhoto(file) {
    if (!file || !file.type.match(/image.*/)){
        if(!file){
            postStatus();
        } else {
            return;
        }
    }
    var fd = new FormData();
    fd.append("image", file);
    fd.append("privacy", document.getElementById('privacy-handler').value);
    var xhr = GetXmlHttpRequest(); 
    xhr.open("POST", "url here");
    slideUp('photo-upload');
    slideDown('photo-manager-txt');
    document.getElementById("photo-manager-txt").innerHTML='<i>Please wait a moment while we process your photo.</i>';
    xhr.onload = function() {
        if(xhr.responseText == '0'){
            document.getElementById('photo-manager-txt').innerHTML='<br />Photo upload failed';
            slideDown('photo-upload');
            return;
        } else {
            document.getElementById('photo-txt').value='grab?v=1&file='+xhr.responseText;
            document.getElementById('photo-manager-txt').innerHTML='Photo uploaded and shared.';
            postStatus();
        }
    }
    xhr.send(fd);
}

这个功能似乎并不奏效。当我打电话的功能,我使用:

This function seems not to be working. When I call the function I'm using:

onClick="uploadPhoto(document.getElementById('ID-HERE').files[0]);"

当我删除 0 文件[] ,它ATLEAST运行 postStatus( ); ,但它不会上传照片。我该如何去修复呢?

When I remove the 0 from files[], it atleast runs postStatus();, but it won't upload the photo. How do I go about fixing this?

推荐答案

在IE中XHR不支持FORMDATA至IE10。您可以安装Windows 8客户preVIEW一试。

The XHR in IE doesn't support FormData until IE10. You may install Windows 8 Customer Preview to have a try.

这篇关于FORMDATA不工作在Internet Explorer?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆