gpt4 book ai didi

javascript - FormData 在 Internet Explorer 中不工作?

转载 作者:搜寻专家 更新时间:2023-10-31 08:12:00 26 4
gpt4 key购买 nike

    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);
}

这个功能似乎不起作用。当我调用我正在使用的函数时:

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

当我从 files[] 中删除 0 时,它至少会运行 postStatus();,但不会上传照片.我该如何解决这个问题?

最佳答案

IE 中的 XHR 直到 IE10 才支持 FormData。您可以安装 Windows 8 Customer Preview 来试一试。

关于javascript - FormData 在 Internet Explorer 中不工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9573607/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com