开发者

POSTing ByteArray Data from AS3 to PHP

I have this:

import JPGEncoder;
var bmd:BitmapData = new BitmapData(stage.stageWidth, stage.stageHeight, true, 0);
var bm:Bitmap = new Bitmap(bmd);
bm.alpha = .5;

stage.addEventListener(MouseEvent.MOUSE_DOWN, screenCap);

function screenCap(e:Event):void {
bm开发者_如何学运维d.draw(this);
var jpgVersion:JPGEncoder = new JPGEncoder( 80 );
var jpgStream:ByteArray  = jpgVersion.encode( bmd );
var loader:URLLoader = new URLLoader();
var request:URLRequest = new URLRequest("http://localhost/takeshot.php");
request.method = URLRequestMethod.POST;
request.data = jpgStream;
loader.load(request);
function dataOnLoad(e:Event){
 trace("Complete..");
}
}

Which takes a screenshot of the stage and is supposed to send the Byte array of the screenshot to PHP through POST data, My PHP just opens a new file, writes post data and closes (for testing purpose). But the $_POST is empty!


$_POST is an array with field -> value pairs. What you send is raw post data. You can retrieve it with file_get_contents('php://input') or from $HTTP_RAW_POST_DATA, but the former is the recommended method.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜