问题描述
我无法发送的ByteArray到我Zend_Amf_server。我得到一个NetConnection.Bad.Call从服务器返回。如果我把一个变量与其它数据类型则ByteArray的正常工作。
我用同样的脚本之前,AMFPHP witouth任何问题。但是,对于这个项目,我真的需要这个在Zend_Amf工作。
AS3:
VAR路径:字符串=/images/picture.jpg;
变种BA:的ByteArray = jpgen coder.en code(bitmap.bitmapData);
VAR NC:的NetConnection =新的NetConnection();
nc.connect(zend_amf_server);
nc.call(Service.saveJPG,新的Responder(ResponseHandler的,的ErrorHandler),路径,BA);
PHP:
类服务{
公共职能saveJPG($路径,$的字节数组){
返回工作;
}
}
我是从Zend的AMF得到同样的错误今晚做的基本上是同样的事情$ C C是$ P $的AMF pviously工作$。这是我有一个的工作。我当场从code唯一不同的位,我只是路过ByteArray的Zend的,而且我明确地设置的objectEncoding。
我不停的服务器,因为我在别处读到我需要做的就渐渐空虚JPG格式 - >数据才能到的ByteArray data P>
AS3:
_service =新的NetConnection();
_service.objectEncoding =即ObjectEncoding.AMF3;
_responder =新的Responder(this._onSuccess,this._onError);
_service.connect(zend_amf_server);
VAR myEn codeR:JPGEn codeR =新JPGEn codeR(qualityValue);
VAR myCapStream:的ByteArray = myEn coder.en code(myBitmapSource); // myBitmapSource是的BitmapData从雪碧画
this._service.call(Remote.savePhotoToServer,this._responder,myCapStream);
PHP:
函数savePhotoToServer($ pInfos)
{
$字节组= $ pInfos;
$ idimage = $这个 - > nameImage(JPG); //调用私有FUNC键的新名称
返程($成功= file_put_contents(./_照片/".$ idimage,$字节组))? $ idimage:$成功;
}
I'm having problems sending a ByteArray over to my Zend_Amf_server. I get a NetConnection.Bad.Call back from the server. If I send a variable with another datatype then ByteArray it works fine.
I used the same script before with AMFPHP witouth any problems. But for this project I really need this to work in Zend_Amf.
AS3:
var path:String = "/images/picture.jpg";
var ba:ByteArray = jpgencoder.encode(bitmap.bitmapData);
var nc:NetConnection = new NetConnection();
nc.connect(zend_amf_server);
nc.call("Service.saveJPG", new Responder(responseHandler, errorHandler), path, ba);
PHP:
class Service{
public function saveJPG($path, $byteArray){
return "worked";
}
}
I was getting the same error from Zend AMF tonight doing basically the same thing with code that previously worked in AMF. Here's what I have that's working. The only bit I spot different from your code is I'm only passing the ByteArray to Zend, and I'm explicitly setting the ObjectEncoding.
I kept getting empty jpgs on the server because I'd read elsewhere that I needed to do ->data to get to the ByteArray data.
AS3:
_service = new NetConnection();
_service.objectEncoding = ObjectEncoding.AMF3;
_responder = new Responder(this._onSuccess, this._onError);
_service.connect(zend_amf_server);
var myEncoder:JPGEncoder = new JPGEncoder( qualityValue );
var myCapStream:ByteArray = myEncoder.encode ( myBitmapSource ); // myBitmapSource is BitmapData drawn from a Sprite
this._service.call("Remote.savePhotoToServer", this._responder, myCapStream);
PHP:
function savePhotoToServer ( $pInfos )
{
$bytearray = $pInfos;
$idimage = $this->nameImage(".jpg"); // calls a private func for a new name
return ( $success = file_put_contents("./_photos/".$idimage, $bytearray) ) ? $idimage : $success;
}
这篇关于发送ByteArray的Zend_Amf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!