ByteArray to MySQL from ActionScript 3 -> PHP via ZendAMF -
i have actionscript 3 application that's sending object php via zendamf. object contains bytearray image.
i have saving bytearray blob so:
$ba = new zend_amf_value_bytearray ( $im->barray ); $data = mysql_real_escape_string ( $ba->getdata () ); $query = "insert image ( bytearray ) values ( '".$data."' );"; $result = mysql_query($query); $error = mysql_error(); if($error) return "error: " . $error; else return true;
this seems working fine , can see image in db (this running local , i'm using sequelpro view db).
the problem when i'm sending bytearray flash, flash reports bytearray length 0.
here return method in php:
$result = mysql_query ( 'select * 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 better way this? appreciated.
thank you
just quick google of zend_amf_value_bytearray
, seems there might problem zend in has problem not serializing byte array.
here few links zend forums talk issue:
- zend_amf not serialize zend_amf_value_bytearray instances
- bytearray not serialize zend_amf_value_bytearray. instead string given
- flex 4 / php data-centric photo transfers
good luck, , hope helps some.
Comments
Post a Comment