作者 lyh

gx

... ... @@ -162,16 +162,14 @@ class ImageController extends Controller
//上传到cos
if($this->upload_location == 1){
$cosService = new CosService();
$is_cos = 1;//上传到cos
$cosService->uploadFile($files,$this->path,$fileName);
}else{
$res = $files->move($url,$fileName);
$is_cos = 0;
if ($res === false) {
return $this->response($files->getError(), Code::USER_ERROR);
}
}
$this->saveMysql($imageModel,$size,$image_type,$fileName,$hash,$is_cos);
$this->saveMysql($imageModel,$size,$image_type,$fileName,$hash,$this->upload_location);
return $this->response('图片资源',Code::SUCCESS,['image'=>$hash]);
}
... ... @@ -241,17 +239,15 @@ class ImageController extends Controller
//同步数据到cos
if($this->upload_location == 1){
$cosService = new CosService();
$is_cos = 1;//上传到cos
$cosService->uploadFile($file,$this->path,$fileName);
}else{
$is_cos = 0;
$res = $file->move($url,$fileName);
if ($res === false) {
return $this->response($file->getError(), Code::USER_ERROR);
}
}
//批量存储
$save_data = $this->saveMysqlAll($save_data,$fileName,$size,$hash,$image_type,$is_cos);
$save_data = $this->saveMysqlAll($save_data,$fileName,$size,$hash,$image_type,$this->upload_location);
$data[] = ['image'=>$hash];
}
$imageModel->insert($save_data);
... ...