Javascript FormData在Internet Explorer中不工作?
当我从Javascript FormData在Internet Explorer中不工作?,javascript,html,ajax,xmlhttprequest,form-data,Javascript,Html,Ajax,Xmlhttprequest,Form Data,当我从文件[]中删除0时,它至少运行postStatus(),但它不会上载照片。我该如何着手解决这个问题 IE中的XHR直到IE10才支持FormData。你可以安装Windows 8客户预览版来试一试。你在说什么版本的IE?我想这就是问题所在,@Jake。直到IE10才支持文件API。 function uploadPhoto(file) { if (!file || !file.type.match(/image.*/)){ if(!file){
文件[]
中删除0
时,它至少运行postStatus()代码>,但它不会上载照片。我该如何着手解决这个问题 IE中的XHR直到IE10才支持FormData。你可以安装Windows 8客户预览版来试一试。你在说什么版本的IE?我想这就是问题所在,@Jake。直到IE10才支持文件API。
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]);"