Commento e post notturno. Beh, c'è anche gente che beve troppi caffè al pomeriggio ...
IL problema della progress bar senza utilizzo di metodi derivati flash non è semplice ed è stato risolto solo da qualche anno con l' arrivo delle XMLHttpRequest livello 2 .
Prendendo spunto da un esempio in Rete, a suo tempo avevo fatto uno script (sempre per via dei troppi caffè), in javascript nativo che adoperava il FormData, nuovo anche lui all' epoca.
Con javascript si invia il file che, una volta arrivato al server, viene preso in carica dal file Carica.php con l' avvertenza che il php $_POST['nome-del-tag-html'] diventa
$_POST['id-del-tag-html] per via del fatto che è stato inviato con un FormData e non con un form normale.
Safari allora non riusciva ancora a visualizzare la progress-bar ma solo le percentuali numeriche, adesso non so.
Tradurre una progress-bar all'interno di una estensione joomla è una faticata ulteriore, che si adoperi jQuery o javascript nativo.
Ciao!
function JSe(el){return document.getElementById(el);}
function Carica(){
var flFile = JSe('fl_file').files[0];
if(!flFile) {return 'file assente!';}
var jsForm = new FormData();
jsForm.append('fl_key', JSe('fl_key').value);
jsForm.append('fl_file', flFile);
var xhr = {};
if(window.ActiveXObject) {xhr = new ActiveXObject;} else {xhr = new XMLHttpRequest;}
if(typeof(xhr.upload) == 'undefined') {JSe('status').innerHTML = 'Impossibile proseguire!<br> XMLHttpRequest livello 2 NON supportato.<br> Browser consigliati: Chrome di Google e Firefox di Mozilla'; return;}
xhr.upload.addEventListener("progress", InProgress, false);
xhr.addEventListener("load", Completato, false);
xhr.addEventListener("error", Errori, false);
xhr.addEventListener("abort", Abortito, false);
xhr.open("POST", "Carica.php");
xhr.setRequestHeader("enctype", "multipart/form-data");
xhr.send(jsForm);
/* ************************ */
function InProgress(event){
JSe("fl_inviati").innerHTML = "Inviati "+ (Math.round(event.loaded /1024)).toString() +" Kbytes di "+ (Math.round(event.total /1024)).toString();
var percent = (event.loaded / event.total) * 100;
JSe("progressBar").value = Math.round(percent);
JSe("fl_status").innerHTML = Math.round(percent)+"% inviato... attendi";
}
function Completato(event){
var a = event.target.responseText.split('tuo_separatore');
JSe("progressBar").value = 0;
if(a[0] == 'si'){
// tuo codice che fai con risposta positiva di upload
}
else {
JSe("fl_status").innerHTML = '<b>'+ a[1] + '</b>';
JSe('fl_report').innerHTML = 'Errore. Procedura interrotta.';
}
}
function Errori(event){ JSe("fl_status").innerHTML = "<b>'js Errore. Upload Fallito</b>"; }
function Abortito(event){ JSe("fl_status").innerHTML = "<b>js Errore. Upload Abortito</b>"; }
}