从 ActionScript 3 到 MySQL 的 ByteArray ->通过 ZendAMF 的 PHP
我有一个 ActionScript 3 应用程序,它通过 ZendAMF 向 PHP 发送一个对象。该对象包含图像中的 byteArray。
我目前将 byteArray 保存到 Blob 中,如下所示:
$ba = new Zend_Amf_Value_ByteArray ( $im->bArray );
$data = mysql_real_escape_string ( $ba->getData () );
$query = "INSERT INTO image ( byteArray ) VALUES ( '".$data."' );";
$result = mysql_query($query);
$error = mysql_error();
if($error)
return "Error: " . $error;
else
return true;
这似乎工作正常,我可以在数据库中看到图像(这是在本地运行,我正在使用 SequelPRO 查看数据库)。
问题是当我将 byteArray 发送回 Flash 时,Flash 报告 byteArray 长度为 0。
这是我在 PHP 中的返回方法:
$result = mysql_query ( 'SELECT * FROM image');
$array = array();
while ( $row = mysql_fetch_assoc ( $result ) )
{
$ba = new Zend_Amf_Value_ByteArray ( $row['byteArray'] );
$image = new Image ();
$image->id = $row['id'];
$image->file = $row['filePath'];
$image->bArray = $ba->getData();
array_push ( $array, $image );
}
return ( $array );
有更好的方法吗? 任何帮助将不胜感激。
谢谢
I have an ActionScript 3 application that's sending an object to PHP via ZendAMF. The object contains a byteArray from an image.
I have it currently saving the byteArray into a Blob like so:
$ba = new Zend_Amf_Value_ByteArray ( $im->bArray );
$data = mysql_real_escape_string ( $ba->getData () );
$query = "INSERT INTO image ( byteArray ) VALUES ( '".$data."' );";
$result = mysql_query($query);
$error = mysql_error();
if($error)
return "Error: " . $error;
else
return true;
This seems to be working fine and I can see the image in the DB (this is running local and I'm using SequelPRO to view the DB).
The problem is when I'm sending the byteArray back to Flash, Flash reports the byteArray length as 0.
Here is my return method in PHP:
$result = mysql_query ( 'SELECT * FROM image');
$array = array();
while ( $row = mysql_fetch_assoc ( $result ) )
{
$ba = new Zend_Amf_Value_ByteArray ( $row['byteArray'] );
$image = new Image ();
$image->id = $row['id'];
$image->file = $row['filePath'];
$image->bArray = $ba->getData();
array_push ( $array, $image );
}
return ( $array );
Is there a better way to do this?
Any help would be greatly appreciated.
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
仅从
Zend_Amf_Value_ByteArray
的快速谷歌来看,Zend 本身可能存在问题,因为它无法正确序列化您的字节数组。以下是讨论此问题的 Zend 论坛的一些链接:
序列化 Zend_Amf_Value_ByteArray
实例
祝你好运,希望这对你有所帮助。
Just from a quick google of
Zend_Amf_Value_ByteArray
, seems that there might be a problem with Zend itself in that it has a problem not properly serializing your byte array.Here are a few links to the Zend forums that talk about this issue:
serialize Zend_Amf_Value_ByteArray
instances
Good luck, and hope this helps you some.