1

我有一个通过 ZendAMF 向 PHP 发送对象的 ActionScript 3 应用程序。该对象包含来自图像的 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 );

有一个更好的方法吗?任何帮助将不胜感激。

谢谢

4

1 回答 1

1

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:

  1. Zend_Amf does not properly serialize Zend_Amf_Value_ByteArray instances
  2. ByteArray does not serialize to Zend_Amf_Value_ByteArray. Instead a string is given
  3. Flex 4 / PHP Data-Centric Photo Transfers

Good luck, and hope this helps you some.

于 2010-12-03T20:11:01.950 回答