PDA

View Full Version : File upload using flex.


overmann
01-19-2011, 05:22 PM
/*Flex code*/

private const UPLOAD_URL:String = "http // myhosting / upload/ upload.php";
private var cer:FileFilter = new FileFilter("Archivos Cer", "*.cer");
private var key:FileFilter = new FileFilter("Archivos Key", "*.key");
private var fileref:FileReference = new FileReference();
private var fileref2:FileReference = new FileReference();


protected function button_clickHandler(event:MouseEvent):void

{


var request:URLRequest = new URLRequest();
request.method = URLRequestMethod.GET;
request.url = UPLOAD_URL;
fileref.upload(request);
fileref2.upload(request);

}

Well, that's the procedure I use to get my files up my server. The "upload.php" in my server is:

<?php
$target = "upload/";
$target = $target . basename( $_FILES['uploaded']['name']) ;
$ok=1;
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
}
else {
echo "Sorry, there was a problem uploading your file.";
}
?>

Is there a way to do this in FLEX only?