-
-
Save anonymous/2a2fef447399a3b8e734 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
fd = new FormData; | |
fd.append("zip", fdata); | |
fd.append("name", $("#ag-name").val()); | |
$("#uploadc-s").html("<progress id='uploadprogress' max='100' value='0'></progress> <span id='progress'>Uploading...</span>"); | |
var xhr = new window.XMLHttpRequest(); | |
var uploaded = false; | |
xhr.upload.addEventListener("progress", function (e) { | |
if (!uploaded && e && e.lengthComputable) { | |
p = (e.loaded / e.total); | |
var percent = Math.round(p * 1000) / 10; | |
$("#uploadprogress").val(e.loaded); | |
$("#uploadprogress").attr("max", e.total); | |
$("#progress").text("Uploading... " + percent + "%"); | |
} | |
}, false); | |
xhr.upload.addEventListener("load", function (e) { | |
uploaded = true; | |
$("#uploadprogress").val(false); | |
$("#uploadprogress").attr("max", false); | |
$("#progress").text("{{ "Checking file"|l }}"); | |
}, false); | |
xhr.addEventListener("readystatechange", function(e) { | |
if (this.readyState === 4) { | |
data = $.parseJSON(xhr.responseText); | |
if (data.success) { | |
window.location = data.url; | |
} else { | |
msg(data.error, MSG_ERROR); | |
$("#uploadc-s").hide(100); | |
$("#uploadc") | |
} | |
} | |
}, false); | |
xhr.open("post", "ajax/upload-map", true); | |
xhr.send(fd); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment