正在显示
1 个修改的文件
包含
2 行增加
和
6 行删除
| @@ -162,16 +162,14 @@ class ImageController extends Controller | @@ -162,16 +162,14 @@ class ImageController extends Controller | ||
| 162 | //上传到cos | 162 | //上传到cos |
| 163 | if($this->upload_location == 1){ | 163 | if($this->upload_location == 1){ |
| 164 | $cosService = new CosService(); | 164 | $cosService = new CosService(); |
| 165 | - $is_cos = 1;//上传到cos | ||
| 166 | $cosService->uploadFile($files,$this->path,$fileName); | 165 | $cosService->uploadFile($files,$this->path,$fileName); |
| 167 | }else{ | 166 | }else{ |
| 168 | $res = $files->move($url,$fileName); | 167 | $res = $files->move($url,$fileName); |
| 169 | - $is_cos = 0; | ||
| 170 | if ($res === false) { | 168 | if ($res === false) { |
| 171 | return $this->response($files->getError(), Code::USER_ERROR); | 169 | return $this->response($files->getError(), Code::USER_ERROR); |
| 172 | } | 170 | } |
| 173 | } | 171 | } |
| 174 | - $this->saveMysql($imageModel,$size,$image_type,$fileName,$hash,$is_cos); | 172 | + $this->saveMysql($imageModel,$size,$image_type,$fileName,$hash,$this->upload_location); |
| 175 | return $this->response('图片资源',Code::SUCCESS,['image'=>$hash]); | 173 | return $this->response('图片资源',Code::SUCCESS,['image'=>$hash]); |
| 176 | } | 174 | } |
| 177 | 175 | ||
| @@ -241,17 +239,15 @@ class ImageController extends Controller | @@ -241,17 +239,15 @@ class ImageController extends Controller | ||
| 241 | //同步数据到cos | 239 | //同步数据到cos |
| 242 | if($this->upload_location == 1){ | 240 | if($this->upload_location == 1){ |
| 243 | $cosService = new CosService(); | 241 | $cosService = new CosService(); |
| 244 | - $is_cos = 1;//上传到cos | ||
| 245 | $cosService->uploadFile($file,$this->path,$fileName); | 242 | $cosService->uploadFile($file,$this->path,$fileName); |
| 246 | }else{ | 243 | }else{ |
| 247 | - $is_cos = 0; | ||
| 248 | $res = $file->move($url,$fileName); | 244 | $res = $file->move($url,$fileName); |
| 249 | if ($res === false) { | 245 | if ($res === false) { |
| 250 | return $this->response($file->getError(), Code::USER_ERROR); | 246 | return $this->response($file->getError(), Code::USER_ERROR); |
| 251 | } | 247 | } |
| 252 | } | 248 | } |
| 253 | //批量存储 | 249 | //批量存储 |
| 254 | - $save_data = $this->saveMysqlAll($save_data,$fileName,$size,$hash,$image_type,$is_cos); | 250 | + $save_data = $this->saveMysqlAll($save_data,$fileName,$size,$hash,$image_type,$this->upload_location); |
| 255 | $data[] = ['image'=>$hash]; | 251 | $data[] = ['image'=>$hash]; |
| 256 | } | 252 | } |
| 257 | $imageModel->insert($save_data); | 253 | $imageModel->insert($save_data); |
-
请 注册 或 登录 后发表评论