parteno da questo link:
http://www.flash-db.com/Tutorials/upload/
che permette da server di caricare qualsiasi immagine e considerarne le sue proprietà,
ho provato a modificarne il codice e anzichè le immagini vorrei aprire i file audio.
In locale tutto ok, ed inoltre ho copiato sia il file swf che il .php su un mio dominio di aruba, ma niente da fare, mi da il messaggio di errore di download....come mai??
vi posto il mio codice:
upload.php :
<?php
//create the directory if doesn't exists (should have write permissons)
if(!is_dir("public/files")) mkdir("public/files");
//move the uploaded file
move_uploaded_file($_FILES['Filedata']['tmp_name'], "public/files/".$_FILES['Filedata']['name']);
chmod("public/files".$_FILES['Filedata']['name'], 0777);
?>
upload.fla :
System.security.allowDomain("http://localhost/");
import flash.net.FileReference;
musica = new Sound();
var listener:Object = new Object();
listener.onSelect = function(selectedFile:FileReference):Void {
testo.text = "File selezionato: "+selectedFile.name+"\n";
musica.loadSound(selectedFile.name, true);
//musica.attachSound(selectedFile.name); //?
//musica.setVolume(50);
selectedFile.upload("upload.php");
};
// the file is starting to upload.
listener.onOpen = function(selectedFile:FileReference):Void {
statusArea.text += "Uploading " + selectedFile.name + "\n";
};
//Possible file upload errors
listener.onHTTPError = function(file:FileReference, httpError:Number):Void {
imagePane.contentPath = "error";
imagePane.content.errorMSG.text = "HTTPError number: "+httpError +"\nFile: "+ file.name;
}
listener.onIOError = function(file:FileReference):Void {
imagePane.contentPath = "error";
imagePane.content.errorMSG.text = "IOError: "+ file.name;
}
listener.onSecurityError = function(file:FileReference, errorString:String):Void {
imagePane.contentPath = "error";
imagePane.content.errorMSG.text = "SecurityError: "+SecurityError+"\nFile: "+ file.name;
}
// the file has uploaded
listener.onComplete = function(selectedFile:FileReference):Void {
// Notify the user that Flash is starting to download the image.
statusArea.text += "Upload finished.\nNow downloading " + selectedFile.name + " to player\n";
//Show file details
details.text = ""
for(i in selectedFile) details.text +=""+i+": "+selectedFile[i]+"\n"
// Call the custom downloadImage() function.
downloadImage(selectedFile.name);
};
//vol.cursore.onRelease(musica.getVolume()+10);
var soundFile:FileReference = new FileReference();
soundFile.addListener(listener);
uploadBtn.onPress = uploadSound;
imagePane.addEventListener("complete", imageDownloaded);
function uploadSound(event:Object):Void {
soundFile.browse([{description:"File Audio", extension:"*.mp3;*.wav"}]);
}
// If the image does not download, the event object's total property
// will equal -1. In that case, display am error message
function imageDownloaded(event:Object):Void {
if(event.total == -1) {
imagePane.contentPath = "error";
}
}
// show uploaded image in scrollPane
function downloadImage(file:Object):Void {
imagePane.contentPath = "./files/" + file;
}
stop();