开发者

ByteArray to MySQL from ActionScript 3 -> PHP via ZendAMF

开发者 https://www.devze.com 2023-01-28 01:55 出处:网络
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 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($开发者_JAVA技巧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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消