4
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);
}
이 함수는 작동하지 않는 것 같습니다. 내가 사용하고 함수를 호출 할 때 :FormData가 Internet Explorer에서 작동하지 않습니까?
onClick="uploadPhoto(document.getElementById('ID-HERE').files[0]);"
나는 files[]
에서 0
은이어야가 postStatus();
실행, 제거,하지만 사진을 업로드하지 않을 때. 이 문제를 해결하려면 어떻게해야합니까?
무슨 IE 버전입니까? – Pointy
Internet Explorer 9 – Jake
[caniuse.com file api] (http://caniuse.com/#search=file%20api) – epascarello