Return to Snippet

Revision: 53488
at November 24, 2011 22:42 by kiroweb


Initial Code
//-- 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 );

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

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

Initial Title
Save ByteArray to file with PHP

Initial Tags
php, actionscript

Initial Language
ActionScript