salve, non trovo l'errore presente in questo apparentemente semplice codice:
dove what è "this.value" di un <input type="file" />.Codice PHP:function checkFileUpload(what) {
var i; // indice
var found = 1; // variabile di controllo
trustExt = new Array("jpg", "jpeg", "bmp", "png"); // elenco estensioni consentite
for (i in trustExt) { // comincio a cercare nell'array
if (found != 0) { // se non l'ho già trovato
found = (getExtension(what) != trustExt[i]) ? 1 : 0; // se l'estensione è diversa resta 1, altrimenti diventa 0
}
}
found == 1 ? alert("File non consentito") : found == 1; // reinizializzo per il prossimo controllo
}
function getExtension(mystring) {
return mystring.substring(mystring.lastIndexOf(".")+1, mystring.length);
}
dove sbaglio?

Rispondi quotando