} else { $return_array = array("errcode" => 'e_2014', "errmsg" => lang('error', 'e_2014') . $upExt, "data" => $msg); } @unlink($tempPath); } if (file_exists($targetPath)) { $return_array = array("errcode" => 'e_2000', "errmsg" => lang('error', 'e_2000'), "data" => $msg); //echo "{'err':'".jsonString($err)."','msg':".$msg."}"; } else { $return_array = array("errcode" => 'e_2015', "errmsg" => lang('error', 'e_2015'), "data" => $msg); } } else { //DEBUG 无权限上传 $return_array = array("errcode" => 'e_2016', "errmsg" => lang('error', 'e_2016'), "data" => $msg); } echo json_ext($return_array); break; } function jsonString($str) { return preg_replace("/([\\\\\\/'])/", '\\\\$1', $str); } function formatBytes($bytes) { if ($bytes >= 1073741824) { $bytes = round($bytes / 1073741824 * 100) / 100 . 'GB'; } elseif ($bytes >= 1048576) { $bytes = round($bytes / 1048576 * 100) / 100 . 'MB'; } elseif ($bytes >= 1024) { $bytes = round($bytes / 1024 * 100) / 100 . 'KB'; } else {
function format_data($data, $data_format_type = 'json') { $return = ''; switch ($data_format_type) { case "json": $return = json_ext($data); break; case "xml": //@header("Content-type: application/xml");//头部输出 $return = array2xml($data); //DEBUG XML 解析 //$return_array = xml2array($return); //TODO 方法二 反向解析XML为数组 此方法位置DOM报错 //$return = arrayxml::createXML('root', $data); //$result = arrayxml::xml2array($result,0); break; } return $return; }