Forum Moderators: coopster

Message Too Old, No Replies

Variables sent to PHP from Flash

         

skywlkr

8:26 pm on Aug 29, 2011 (gmt 0)

10+ Year Member



I am buliding an image manipulator swf and I got stuck at the last step. My swf uses a function to save the part of its content as a jpg. Here's the function:

function createJPG() {
var jpgSource:BitmapData = new BitmapData (spBoard.width, spBoard.height);
jpgSource.draw(spBoard);

var jpgEncoder:JPGEncoder = new JPGEncoder(100);
var jpgStream:ByteArray = jpgEncoder.encode(jpgSource);

var request:URLRequest = new URLRequest ( 'save.php' );
var loader: URLLoader = new URLLoader();
request.contentType = 'application/octet-stream';
request.method = URLRequestMethod.POST;
request.data = jpgStream;
loader.load( request );
var jump:URLRequest = new URLRequest ("http://whatever.com");
navigateToURL(jump, "_self");
}


And the php:

<?php 

file_put_contents('whatever.jpg', $GLOBALS["HTTP_RAW_POST_DATA"]);

?>


This works, the jpg is created on the server. However, what I want is to send the filename from the swf. I tried it this way:

var request:URLRequest = new URLRequest ( 'save.php?name=whatever.jpg' );


and in the php:

file_put_contents($_GET['name'], $GLOBALS["HTTP_RAW_POST_DATA"]); 


But this doesn't work. I need the swf function to navigate to a static url, so that cannot be changed. I cant figure out how to send the filename and the jpg together to the php.

Thanks for any help!

coopster

2:36 pm on Aug 31, 2011 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, skywlkr.

Did you look at the request to see if the QUERY_STRING was actually being passed to the server? If not, you have a Flash issue, not PHP.