我正在使用基于flash和php的应用程序。我试图以下面的格式将图像作为字节数组发送到amfphp:
**
array(
'name'=>'Scott',
'age'=>29,
'image'=>array('first img byte array','second img byte array','so on..')
)
**
虽然,我从Web服务接收数组,但我通过上面的格式得到{'data':null}。但是,虽然我只发送一个再见数组,然后一切正常,下面是我的工作格式:
**
array(
'name'=>'Scott',
'age'=>29,
'image'=>'first img bye array'
)
**
这是我的函数(PHP):
/**
* Get Flash Object
* (non-PHPdoc)
* @param object $objectFormData
* @return string url of uploaded image
*/
function sendFormData($objectFormData){
global $isAccessGranted;
if ($isAccessGranted) {
if(is_object($objectFormData)){
return $this->SaveAsJPEG($objectFormData);
}elseif(is_array($objectFormData)){
$objectFormData = (object) $objectFormData;
return $this->SaveAsJPEG($objectFormData);
}else{
return "No Object or Array data type recived. it's ".gettype($objectFormData);
}
} else {
return 'Access Denied';
}
}
这是我的SaveAsJPEG函数:
/**
* Save image from the given bytearray
* and return the path of the saved image
*/
function SaveAsJPEG($ba, $compressed = false)
{
if(!file_exists($this->output_dir) || !is_writeable($this->output_dir))
trigger_error ("please create a 'flashupload' directory first with write access", E_USER_ERROR);
$data = $ba->data;
if($compressed)
{
if(function_exists(gzuncompress))
{
$data = gzuncompress($data);
} else {
trigger_error ("gzuncompress method does not exists, please send uncompressed data", E_USER_ERROR);
}
}
file_put_contents($this->output_dir . "/rawdata.jpeg", $data);
return $this->server_url . $this->output_dir . "/rawdata.jpeg";
}
任何人都可以告诉我,我们如何在amfphp中处理多个byt数组数据。
非常感谢...