本文介绍了为什么bitmapdata没有通过flash发布到服务器端?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这里是我用来发布位图数据到服务器端的代码( 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);
$ / code $ / pre
$ b $ p 这里是服务器端的代码:
file_put_contents('data.txt',var_export($ _ POST)。var_export($ _ FILES)。\r\\\
。$ _SERVER ['REMOTE_ADDR ]);
但是在 data.txt
中只有这个:
127.0.0.1
最后, trace
的输出是:
in savePicToServer
[object BitmapData]
完成savePicToServer
我的代码有什么问题?
解决方案你试过?
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
?
这篇关于为什么bitmapdata没有通过flash发布到服务器端?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!