Why is the bitmapdata not posted to server side with flash?

心已入冬 提交于 2019-12-04 06:44:12

问题


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?


回答1:


did you try $HTTP_RAW_POST_DATA?



来源:https://stackoverflow.com/questions/3169831/why-is-the-bitmapdata-not-posted-to-server-side-with-flash

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!