我正在开发一个基于 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 中处理多个字节数组数据。
非常感谢...