Why is the bitmapdata not posted to server side wi

2020-05-07 18:15发布

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条回答
小情绪 Triste *
2楼-- · 2020-05-07 18:39
登录 后发表回答