Created
September 24, 2016 19:33
-
-
Save amici-fos/72414570ff89e0e3827993bf022972c7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function UploadFile(file) { | |
var xhr = new XMLHttpRequest(); | |
xhr.upload.addEventListener("progress", function(e) { | |
var pc = parseInt((e.loaded / e.total * 100)); | |
document.getElementById("progressbar").value= pc; | |
document.getElementById("progressbarstatus").innerHTML= pc +"% upload done"; | |
}, false); | |
xhr.onreadystatechange = function(e) { | |
if (xhr.readyState ==200) { | |
console.log(e); | |
} | |
}; | |
var formData = new FormData(); | |
formData.append('file', file); | |
xhr.open("POST",uploadurl, true); | |
//xhr.setRequestHeader("X_FILENAME", file.name); | |
xhr.send(formData); | |
return false; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment