Ho trovato un form in flash con allegato, perfettamente funzionante, ma era costruito con i componenti di flash, quindi ho sostituito i componenti con elementi normali , ma se adesso allego un file non ho nessuna risposta dalla pagina php e la mail non viene inviata.

Posto il codice:

codice originale:

import flash.net.FileReference;
var file_ref:FileReference = new FileReference();
var obj:Object = new Object();
output_txt.text = browse_txt.text=message_txt.text="";
function sendMail() {
var mail:LoadVars = new LoadVars();
var ricevi:LoadVars = new LoadVars();
mail.message = message_txt.text;
ricevi.onLoad = function(success:Boolean) {
if (success) {
trace("success");
output_txt.text = "Grazie, la mail è stata inviata...";
browse_txt.text = message_txt.text="";
send_btn.enabled = true;
}
};
mail.sendAndLoad("mail.php", ricevi, "POST");
}
obj.onSelect = function() {
output_txt.text = "";
if (file_ref.size<=3110000) {
browse_txt.text = file_ref.name;
} else {
output_txt.text = "Attenzione il file non può superare i 100kb";
}
};
obj.onComplete = function() {
output_txt.text = "Grazie, la mail è stata inviata...";
browse_txt.text = sender_txt.text=email_txt.text=message_txt.text="" ;
send_btn.enabled = true;
};
file_ref.addListener(obj);
browse_btn.clickHandler = function() {
file_ref.browse([{description:"zip", extension:"*.ZIP;*.zip"}]);
};
send_btn.clickHandler = function() {
if (browse_txt.text != "") {
var sendermessage:String = message_txt.text;
file_ref.upload("mail.php?message="+sendermessage+ "&attach=true");
} else {
sendMail();
}
output_txt.text = "un attimo...";
this.enabled = false;
};



codice modificato da me:

//inizializza
import flash.net.FileReference;
var file_ref:FileReference = new FileReference();
var obj:Object = new Object();
output_txt.text = band_txt.text=genere_txt.text=allegato_txt.text="" ;
//sendMail
function sendMail() {
var mail:LoadVars = new LoadVars();
var ricevi:LoadVars = new LoadVars();
mail.message = "Band: "+band_txt.text+" - Genere: "+genere_txt.text;
ricevi.onLoad = function(success:Boolean) {
if (success) {
trace("success");
output_txt.text = "La richiesta è stata inoltrata correttamente.";
band_txt.text = genere_txt.text=allegato_txt.text="";
allega.enabled = true;
invia.enabled = true;
invier._alpha = 0;
}
};
mail.sendAndLoad("mail.php", ricevi, "POST");
}
//Controllo dimensione
obj.onSelect = function() {
output_txt.text = "";
if (file_ref.size<=3100000) {
allegato_txt.text = file_ref.name;
} else {
allegato_txt.text = "Attenzione il file non può superare i 3MB";
}
};
//Oggetto completo
obj.onComplete = function() {
output_txt.text = "La richiesta è stata inoltrata correttamente.";
band_txt.text = genere_txt.text=allegato_txt.text="";
allega.enabled = true;
invia.enabled = true;
invier._alpha = 0;
};
//controllo estensione
file_ref.addListener(obj);
allega.onPress = function() {
file_ref.browse([{description:"zip", extension:"*.ZIP;*.zip"}]);
};
//invia
invia.onPress = function() {
if (allegato_txt.text != "" && allegato_txt.text != "Attenzione il file non può superare i 3MB") {
var sendermessage:String = "Band: "+band_txt.text+" - Genere: "+genere_txt.text;
file_ref.upload("mail.php?message="+sendermessage+ "&attach=true");
} else {
sendMail();
}
output_txt.text = "Invio in corso...";
invia.enabled = false;
allega.enabled = false;
invier._alpha = 100;
};



in oltre non capisco che evento sia clickHandler che assegnato ai pulsanti normali non da nessun risultato mentre sui pulsanti componenti è come onRelease...