Posted By

kiroweb on 11/24/11


Tagged

php actionscript


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

jbyerson


Save ByteArray to file with PHP


 / Published in: ActionScript
 

URL: http://blog.joa-ebert.com/2006/05/01/save-bytearray-to-file-with-php/

A short snippet of code to save a ByteArray into any file

  1. //-- your byte array you want to save
  2. var bytes: ByteArray = new ByteArray();
  3.  
  4. //-- set up correct url request using post in binary mode
  5. var request:URLRequest = new URLRequest ( 'http://pathto/save.php' );
  6. var loader: URLLoader = new URLLoader();
  7. request.contentType = 'application/octet-stream';
  8. request.method = URLRequestMethod.POST;
  9. request.data = bytes;
  10. loader.load( request );
  11.  
  12. And of course you need a PHP file like this:
  13.  
  14. $fp = fopen( 'file.txt', 'wb' );
  15. fwrite( $fp, $GLOBALS[ 'HTTP_RAW_POST_DATA' ] );
  16. fclose( $fp );

Report this snippet  

You need to login to post a comment.