Here is the code I used to post the bitmapdata to server side(PHP):
private function savePicToServer(bmpData:BitmapData):void
{
trace("in savePicToServer");
trace(bmpData);
var jpgEncoder:JPGEncoder = new JPGEncoder(85);
var jpgStream:ByteArray = jpgEncoder.encode(bmpData);
var loader:URLLoader = new URLLoader();
var header:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream");
var request:URLRequest = new URLRequest("http://localhost/test.php");
request.requestHeaders.push(header);
request.method = URLRequestMethod.POST;
request.data = jpgStream;
loader.load(request);
trace("finish savePicToServer");
}
Here is the code at server side:
file_put_contents('data.txt',var_export($_POST) . var_export($_FILES) . "\r\n" . $_SERVER['REMOTE_ADDR']);
But in data.txt
only this:
127.0.0.1
Finally the trace
output is :
in savePicToServer
[object BitmapData]
finish savePicToServer
What's wrong with my code above?
did you try
$HTTP_RAW_POST_DATA
?