/ Published in: ActionScript

A short snippet of code to save a ByteArray into any file
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
//-- your byte array you want to save var bytes: ByteArray = new ByteArray(); //-- set up correct url request using post in binary mode var request:URLRequest = new URLRequest ( 'http://pathto/save.php' ); var loader: URLLoader = new URLLoader(); request.contentType = 'application/octet-stream'; request.method = URLRequestMethod.POST; request.data = bytes; loader.load( request ); And of course you need a PHP file like this: $fp = fopen( 'file.txt', 'wb' ); fwrite( $fp, $GLOBALS[ 'HTTP_RAW_POST_DATA' ] ); fclose( $fp );
URL: http://blog.joa-ebert.com/2006/05/01/save-bytearray-to-file-with-php/
Comments
