Link to home
Start Free TrialLog in
Avatar of jasonb2
jasonb2

asked on

How to pass binary data from AS3 Flash to PHP

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;

myData.data = variables;
m_uloader = new URLLoader();
m_uloader.dataFormat = URLLoaderDataFormat.TEXT;
m_uloader.load(myData);


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 :)
ASKER CERTIFIED SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial