Avatar of 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;

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 :)
Adobe FlashScripting LanguagesPHP

Avatar of undefined
Last Comment
Dave Baldwin

8/22/2022 - Mon
Dave Baldwin

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.