troubleshooting Question

How to pass binary data from AS3 Flash to PHP

Avatar of jasonb2
jasonb2 asked on
PHPAdobe FlashScripting Languages
1 Comment1 Solution917 ViewsLast Modified:
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 :)
Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros