Created
July 24, 2019 18:52
-
-
Save talcual/d97913f82ae81e6c0416bcea59c44b7b 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 upfiles(model, method, args, filement, backcall){ | |
var doc = eval(document.getElementById(filement)); | |
console.log(doc); | |
var docx = doc.files; | |
var formData = new FormData(); | |
var ins = doc.files.length; | |
for (var x = 0; x < ins; x++) { | |
formData.append("element[]", docx[x]); | |
} | |
formData.append('model', model); | |
formData.append('method', method); | |
formData.append('args', args); | |
var xhr = new XMLHttpRequest(); | |
xhr.upload.addEventListener('progress', onprogressHandler, false); | |
xhr.open('POST', 'app.php', true); | |
xhr.onreadystatechange = function () { | |
if(xhr.readyState === XMLHttpRequest.DONE && xhr.status === 200) { | |
let r = JSON.parse(xhr.responseText); | |
if(typeof backcall == 'function'){ | |
backcall(r); | |
} | |
} | |
}; | |
xhr.send(formData); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment