Trying to pass the id received by the uploadFile function to the progressHandler function, while still needing the "event" to work. Struggling to make it happen, can someone provide assistance?
function uploadFile(arquivo, id) {
alert(id)
//FLUIGC.loading('#painel_inclusao_planilha').show();
var file = _(id).files[0];
// alert(file.name+" | "+file.size+" | "+file.type);
var formdata = new FormData();
formdata.append(id, file);
var ajax = new XMLHttpRequest();
ajax.upload.addEventListener("progress", progressHandler, false);
//ajax.addEventListener("load", completeHandler, false);
ajax.addEventListener("error", errorHandler, false);
ajax.addEventListener("abort", abortHandler, false);
ajax.open("POST", ""); // http://www.developphp.com/video/JavaScript/File-Upload-Progress-Bar-Meter-Tutorial-Ajax-PHP
//use file_upload_parser.php from above url
ajax.send(formdata); }
function progressHandler(event) {
//_("loaded_n_total").innerHTML = "Uploaded " + event.loaded + " bytes of " + event.total;
var percent = (event.loaded / event.total) * 100;
console.log('percent ---> ' + percent)
if (percent === 100) {
console.log('Upload concluído')
ativarBotaoUpload()
FLUIGC.loading('#painel_inclusao_planilha').hide();
}
//_("progressBar").value = Math.round(percent);
//_("status").innerHTML = Math.round(percent) + "% concluído... por favor, aguarde"; }