Saving an image from Flash on the server under different name
I followed this que开发者_如何学JAVAstion: flash Actionscript 3 and php image upload I copied the code:
function uploadFile( e:Event ):void
{
fileRef.upload( new URLRequest( "http://localhost/php5dev/test/upload_script.php" ), "as3File", false );
}
and
<?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 />" );
?>
It works great, I just need to know how to save the image under a specific name, how do I pass an argument to the php script? or is that not necessary, can I change it before calling the script?
How would I then call URLrequest to show user the file he uploaded ? Thanks, for any answers!
You could send the filename via a GET query:
fileRef.upload( new URLRequest( "http://localhost/php5dev/test/upload_script.php?filename=myFile.txt" ), "as3File", false );
And then retrieve it in PHP as $_GET['filename'];
As a word of advice, be careful with those scripts since they are very insecure (one could upload any file to your server and exploit it very easily).
精彩评论