Here is the AS3 code, it's just some quick and dirty timeline code:
var fileRef:FileReference = new FileReference();
fileRef.addEventListener( Event.SELECT, uploadFile );
fileRef.addEventListener( ProgressEvent.PROGRESS, fileUploadProgress );
fileRef.addEventListener( Event.COMPLETE, fileUploadComplete );
button.addEventListener( MouseEvent.CLICK, browseForFile );
function browseForFile( e:Event ):void
{
fileRef.browse();
}
function uploadFile( e:Event ):void
{
fileRef.upload( new URLRequest( "http://localhost/php5dev/test/upload_script.php" ), "as3File", false );
}
function fileUploadProgress( e:ProgressEvent ):void
{
trace( ( e.bytesLoaded / e.bytesTotal ) * 100 );
}
function fileUploadComplete( e:Event ):void
{
trace( "upload complete" );
}
here is the PHP code:
<?php
$target = "uploads/" . basename( $_FILES[ "as3File" ][ "name" ] );
if ( move_uploaded_file( $_FILES[ "as3File" ][ "tmp_name" ], $target ) )
echo( "file upload success<bt />" );
else
echo( "error uploading file<br />" );
?>
Hope this helps, let me know if you need me to clarify anything.