正在显示
1 个修改的文件
包含
4 行增加
和
7 行删除
| @@ -121,17 +121,16 @@ class ImageController extends Controller | @@ -121,17 +121,16 @@ class ImageController extends Controller | ||
| 121 | ]); | 121 | ]); |
| 122 | $files = $this->request->file('image'); | 122 | $files = $this->request->file('image'); |
| 123 | $size = $files->getSize(); | 123 | $size = $files->getSize(); |
| 124 | - var_dump($size); | ||
| 125 | - die(); | 124 | + $image_type = $files->getClientOriginalExtension(); |
| 126 | if (empty($files)) { | 125 | if (empty($files)) { |
| 127 | $this->response('没有上传的文件!', 400); | 126 | $this->response('没有上传的文件!', 400); |
| 128 | } | 127 | } |
| 129 | $type = $this->request->post('type','single'); | 128 | $type = $this->request->post('type','single'); |
| 130 | $this->setUrl(); | 129 | $this->setUrl(); |
| 131 | if ($type == 'multi') { | 130 | if ($type == 'multi') { |
| 132 | - return $this->multi($files); | 131 | + return $this->multi($files,$size,$image_type); |
| 133 | }else{ | 132 | }else{ |
| 134 | - return $this->single($files); | 133 | + return $this->single($files,$size,$image_type); |
| 135 | } | 134 | } |
| 136 | } | 135 | } |
| 137 | 136 | ||
| @@ -143,7 +142,7 @@ class ImageController extends Controller | @@ -143,7 +142,7 @@ class ImageController extends Controller | ||
| 143 | * @method :post | 142 | * @method :post |
| 144 | * @time :2023/6/17 16:30 | 143 | * @time :2023/6/17 16:30 |
| 145 | */ | 144 | */ |
| 146 | - public function single($files){ | 145 | + public function single($files,$size,$image_type){ |
| 147 | $hash = hash_file('md5', $files->getPathname()); | 146 | $hash = hash_file('md5', $files->getPathname()); |
| 148 | //查看文件是否存在 | 147 | //查看文件是否存在 |
| 149 | $imageModel = new ImageModel(); | 148 | $imageModel = new ImageModel(); |
| @@ -159,8 +158,6 @@ class ImageController extends Controller | @@ -159,8 +158,6 @@ class ImageController extends Controller | ||
| 159 | $cosService->uploadFile($files,$this->path,$fileName); | 158 | $cosService->uploadFile($files,$this->path,$fileName); |
| 160 | }else{ | 159 | }else{ |
| 161 | $res = $files->move($url,$fileName); | 160 | $res = $files->move($url,$fileName); |
| 162 | - $size = $res->getSize(); | ||
| 163 | - $image_type = $files->getClientOriginalExtension(); | ||
| 164 | if ($res === false) { | 161 | if ($res === false) { |
| 165 | return $this->response($files->getError(), Code::USER_ERROR); | 162 | return $this->response($files->getError(), Code::USER_ERROR); |
| 166 | } | 163 | } |
-
请 注册 或 登录 后发表评论