コード例 #1
0
ファイル: upload_helper.php プロジェクト: bblue000/temp_tzfc
function common_check_upload_input($CI)
{
    $fn = NULL;
    $headers = $CI->input->request_headers(TRUE);
    if (isset($headers)) {
        $keys = array('X_FILENAME', 'X-FILENAME');
        // IIS 会将头部改成第二个
        foreach ($headers as $key => $value) {
            if (array_search(strtoupper($key), $keys)) {
                $fn = $value;
                break;
            }
        }
    }
    // $fn = $CI->input->get_request_header('X_FILENAME', TRUE);
    if (!$fn) {
        return common_result(404, '请选择上传的文件');
    }
    $validFormats = array('jpg', 'gif', 'png', 'jpeg');
    $ext = pathinfo($fn, PATHINFO_EXTENSION);
    if (!isset($ext)) {
        return common_result(500, '文件格式不支持: ' . $ext);
    }
    $ext = strtolower($ext);
    if (!in_array($ext, $validFormats)) {
        return common_result(500, '文件格式不支持: ' . $ext);
    }
    unset($validFormats);
    return common_result_ok($ext);
}
コード例 #2
0
ファイル: MY_Controller.php プロジェクト: bblue000/temp_tzfc
 public function check_param_api($param_name)
 {
     $val = $this->input->get_post($param_name, TRUE);
     if (!isset($val)) {
         echo json_encode(common_result(400, 'No param \'' . $param_name . '\'', 'You should provide \'' . $param_name . '\' as a parameter'));
         exit(EXIT_USER_INPUT);
     }
     return $val;
 }
コード例 #3
0
ファイル: API.php プロジェクト: bblue000/temp_tzfc
 /**
  * 不正确/非正常的API返回结果,形如:
  * 
  * {'code':10001, 'msg':'xxx err', 'data':null}
  *
  * @return	array
  */
 public function ex($code, $data = NULL)
 {
     if (isset($this->apicode)) {
         if (isset($this->apicode[$code])) {
             return common_result($code, $this->apicode[$code], $data);
         }
         return common_result($code, '未定义的错误码: ' . $code, $data);
     }
     return common_result($code, '未定义错误码列表', $data);
 }
コード例 #4
0
ファイル: upload.php プロジェクト: bblue000/temp_tzfc
 public function house()
 {
     $ext = $this->common_check_input();
     $uid = get_session_uid();
     if (!isset($uid)) {
         echo json_encode(common_result(400, '操作用户未知'));
         return;
     }
     $tempFileName = $this->generateHouseFileName($ext);
     $tempFilePath = 'uploads/house/' . $uid . '/';
     $tempFileAbsPath = FCPATH . $tempFilePath;
     if (!file_exists($tempFileAbsPath)) {
         mkdir($tempFileAbsPath);
     }
     file_put_contents($tempFileAbsPath . $tempFileName, file_get_contents('php://input'));
     echo json_encode(common_result_ok($tempFilePath . $tempFileName));
 }