So the function below works exactly as I want it to except it only sends one of the initial files (the argument is an array of files). When I try to adjust the current function it affects the script in ways that I don't really understand...
Honestly I might just iterate through the array and then ignore the rest of the script, but I wanted to post to see if anyone else could explain what's going on because it irritates me that I can't figure it out...
Any help would be appreciated!!
function readfiles(files) {
// debugger;
var formData = tests.formdata ? new FormData() : null;
for (var i = 0; i < files.length; i++) {
if (tests.formdata) formData.append('file ', files[i]);
previewfile(files[i]);
}
// now post a new XHR request
if (tests.formdata) {
var xhr = new XMLHttpRequest();
xhr.open('POST', './file_upload_parser.php');
xhr.onload = function() {
progress.value = progress.innerHTML = 100;
};
if (tests.progress) {
xhr.upload.onprogress = function (event) {
if (event.lengthComputable) {
var complete = (event.loaded / event.total * 100 | 0);
progress.value = progress.innerHTML = complete;
}
}
}
xhr.send(formData);
}
}