LogInfo ( "---------处理文件---------" );
if (file_exists ( $file ['tmp_name'] )) {
$params ['fileName'] = $file ['name'];
$file_content = file_get_contents ( $file ['tmp_name'] );
$file_content_deflate = gzcompress ( $file_content );
$params ['fileContent'] = base64_encode ( $file_content_deflate );
$log->LogInfo ( "压缩后文件内容为>" . base64_encode ( $file_content_deflate ) );
} else {
$log->LogInfo ( ">>>>文件上传失败<<<<<" );
}
}
}
/**
* 讲数组转换为string
*
* @param $para 数组
* @param $sort 是否需要排序
* @param $encode 是否需要URL编码
* @return string
*/
function createLinkString($para, $sort, $encode) {
if($para == NULL || !is_array($para))
return "";
$linkString = "";
if ($sort) {
$para = argSort ( $para );
}
while ( list ( $key, $value ) = each ( $para ) ) {
if ($encode) {
$value = urlencode ( $value );
}
$linkString .= $key . "=" . $value . "&";
}
// 去掉最后一个&字符
$linkString = substr ( $linkString, 0, count ( $linkString ) - 2 );
return $linkString;
}
/**
* 对数组排序
*
* @param $para 排序前的数组
* return 排序后的数组
*/
function argSort($para) {
ksort ( $para );
reset ( $para );
return $para;
}