FormData 在 Internet Explorer 中不起作用
FormData not working in 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);
}
此功能似乎不起作用。当我调用我正在使用的函数时:
onClick="uploadPhoto(document.getElementById('ID-HERE').files[0]);"
当我从files[]
中删除0
时,它至少运行postStatus();
,但它不会上传照片。我该如何解决这个问题?
IE 中的 XHR 在 IE10 之前不支持 FormData。您可以安装 Windows 8 客户预览版进行尝试。
相关文章:
- 在Internet Explorer中,向所选内容添加选项不起作用
- 鼠标事件在 Internet Explorer 中不起作用
- 输入类型的图像在Internet Explorer中不起作用,但在Chrome和Firefox中起作用
- 包含jquery的Javascript在Internet Explorer中不起作用
- onClick和onClientClick事件一起使用.在Internet Explorer中不起作用
- Javascript图像动画在Firefox或Internet Explorer中不起作用
- 使用JS固定标题的表在Internet explorer中不起作用
- Angular $templateCache在 Internet Explorer 中不起作用
- 滑块图像在Internet Explorer中不起作用,但在其他浏览器中有效
- 带有 Internet Explorer 8/9 的 Editor Ace 不起作用
- Window.location 在 Internet Explorer 中不起作用
- Ajax POST 请求在 Internet Explorer 中不起作用
- 脚本在 Internet Explorer 中不起作用
- 在第二次加载时更改 iframe 样式,在 Internet Explorer 9 中不起作用
- 流体布局在 Internet Explorer 7 和 8 中不起作用
- blockUI 在 Internet Explorer 上不起作用
- Javascript在Internet Explorer上不起作用
- 屏幕键盘在 Internet Explorer 中不起作用
- jQuery 动画在 Internet Explorer 中不起作用
- 元标记中的JavaScript在Firefox和Internet Explorer上不起作用