How to pass binary data from AS3 Flash to PHP

jasonb2 used Ask the Experts™
Hi gurus,
I'm using PHP to record a raw screenshot to a folder on the server. Unfortunately getting the binary data into PHP is corrupting the data.

I've tested it and in flash my data is 40k, but in PHP it's about 80k.
Here's my FLASH code:

var myData:URLRequest = new URLRequest( "saveShot.php" );
myData.method = URLRequestMethod.POST;
var variables:URLVariables = new URLVariables();

var pixels:ByteArray = myScreenShotData;
variables.image = pixels; = variables;
m_uloader = new URLLoader();
m_uloader.dataFormat = URLLoaderDataFormat.TEXT;

And here's my PHP (saveShot.php) code:

$imageBmd = $_POST['image'];
$filename = "someFile.raw";
file_put_contents( $filename, $imageBmd, LOCK_EX);

So, I'm wondering how do I stop this process from corrupting my data?
With Thanks :)
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Fixer of Problems
Most Valuable Expert 2014
I think the problem is that you are not sending and receiving it as a 'file' but just some text.  There is special handling required for a binary file.  I believe the file data is sent encoded, either base64 or hex which accounts for the increased data size.  But since it is not being sent and received properly, it is not being decoded properly.  This page seems to show a variety of things, maybe one can help you:

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial