Esempio n. 1
0
 function upload($file)
 {
     global $_G;
     $picService = Alibaba::Pic();
     if (is_string($file)) {
         $file = file_get_contents(ROOT_PATH . $file);
     } else {
         $file = file_get_contents($file['tmp_name']);
     }
     if (!$file) {
         false;
     }
     $response = $picService->savePic($this->dir, $this->name, $file);
     if ($response->getStatus() && $response->isSuccess()) {
         $result = $response->getResult();
         return $result[0]->fullUrl;
     } else {
         $code = array(200 => "请求成功", 400 => "参数错误", 404 => "图片不存在", 405 => "目录不存在", 408 => "图片大小超限", 406 => "目录非空不能删除", 406 => "存在同名目录或文件", 408 => "请求超时", 500 => "系统错误");
         $codeInt = $response->getStatus();
         $this->code = $codeInt;
         $this->msg = $code[$codeInt];
         $msg = '图片上传错误,错误代码:' . $codeInt . ',错误信息:' . $code[$codeInt];
         L($msg);
     }
 }
Esempio n. 2
0
 function baichuan_update($file)
 {
     $picService = Alibaba::Pic();
     $target = date('Y') . '/' . date('m');
     $name = date('Ymd-His') . '_' . strtolower(rand(1, 1000000)) . '.jpg';
     $file = file_get_contents($file['tmp_name']);
     $response = $picService->savePic($target, $name, $file);
     if ($response->getStatus() && $response->isSuccess()) {
         $result = $response->getResult();
         $picurl = $result[0]->fullUrl;
         $this->oriName = 'org_file_name';
         $this->fileSize = '1000';
         $this->fileType = '.jpg';
         $this->fullName = $picurl;
         $this->filePath = $target;
         $this->fileName = $name;
         $this->stateInfo = $this->stateMap[0];
     } else {
         $code = array(200 => "请求成功", 400 => "参数错误", 404 => "图片不存在", 405 => "目录不存在", 408 => "图片大小超限", 406 => "目录非空不能删除", 406 => "存在同名目录或文件", 408 => "请求超时", 500 => "系统错误");
         $codeInt = $response->getStatus();
         $msg = 'flash图片上传错误,错误代码:' . $codeInt . ',错误信息:' . $code[$codeInt];
         L($msg);
         $this->stateInfo = $this->getStateInfo("ERROR_WRITE_CONTENT");
         return;
     }
 }