
Question:
recently i am going through a project of badge-builder with action-script and flash.now i need some help for image uploading from the flash interface to the server and showing it back in the flash interface,
the back-end programing language is php and i am using action-scrip 3 and flash cs5
can anyone please give me a right direction how to achieve this job.
Thank you very much.
Solution:1
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.
Solution:2
use the FileReference AS3 class to get a file into Flash, then use the FileReference.upload() method to send the file to a php script that will put the file on the server. Once that is done, do a URLRequest on the uploaded file to display it back in Flash. This is just the theory, I can add code if you need some help with that.
Solution:3
yes yes its working still the product is in production mode just 2 nd day here is the link you can check
http://sunmicrosoft.com/badgebuilder/
thank you very much for you help
Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
EmoticonEmoticon