Save ByteArray to file with PHP


/ Published in: ActionScript
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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 );

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.