作者 lyh

gx

@@ -162,7 +162,7 @@ class ImageController extends Controller @@ -162,7 +162,7 @@ class ImageController extends Controller
162 $this->response('没有上传的文件!', Code::USER_ERROR); 162 $this->response('没有上传的文件!', Code::USER_ERROR);
163 } 163 }
164 $type = $this->request->post('type','single'); 164 $type = $this->request->post('type','single');
165 - $this->setUrl(); 165 + $this->setUrl($files);
166 if ($type == 'multi') { 166 if ($type == 'multi') {
167 return $this->multi($files); 167 return $this->multi($files);
168 }else{ 168 }else{
@@ -197,6 +197,7 @@ class ImageController extends Controller @@ -197,6 +197,7 @@ class ImageController extends Controller
197 $image_type = $files->getClientOriginalExtension(); 197 $image_type = $files->getClientOriginalExtension();
198 $fileName = uniqid().rand(10000,99999).'.'.$image_type; 198 $fileName = uniqid().rand(10000,99999).'.'.$image_type;
199 //上传到cos 199 //上传到cos
  200 + //TODO::设置上传文件大小
200 if($this->upload_location == 1){ 201 if($this->upload_location == 1){
201 $cosService = new CosService(); 202 $cosService = new CosService();
202 $cosService->uploadFile($files,$this->path,$fileName); 203 $cosService->uploadFile($files,$this->path,$fileName);
@@ -371,11 +372,24 @@ class ImageController extends Controller @@ -371,11 +372,24 @@ class ImageController extends Controller
371 * @method :post 372 * @method :post
372 * @time :2023/7/18 15:36 373 * @time :2023/7/18 15:36
373 */ 374 */
374 - public function setUrl(){ 375 + public function setUrl($files){
375 //A端上传 376 //A端上传
376 if(isset($this->param['refer_type']) && $this->param['refer_type'] == 1){ 377 if(isset($this->param['refer_type']) && $this->param['refer_type'] == 1){
377 $this->path = $this->uploads['path_a'].'/'.$this->image_type[$this->param['refer']].'/'.date('Y-m'); 378 $this->path = $this->uploads['path_a'].'/'.$this->image_type[$this->param['refer']].'/'.date('Y-m');
378 }else{ 379 }else{
  380 + //TODO::设置上传文件大小(B端上传)
  381 + $max = config('upload.default_b_image')['size']['max'];
  382 + if(in_array($files)){
  383 + foreach ($files as $file){
  384 + if ($file->getSize() > $max) {
  385 + return $this->response('图片最大为500K',Code::SYSTEM_ERROR);
  386 + }
  387 + }
  388 + }else{
  389 + if ($files->getSize() > $max) {
  390 + return $this->response('图片最大为500K',Code::SYSTEM_ERROR);
  391 + }
  392 + }
379 if(!isset($this->param['upload_method'])){ 393 if(!isset($this->param['upload_method'])){
380 //根据项目上传标识区分上传到cos/本地 394 //根据项目上传标识区分上传到cos/本地
381 $projectModel = new Project(); 395 $projectModel = new Project();
@@ -22,6 +22,14 @@ return [ @@ -22,6 +22,14 @@ return [
22 'path_b' => '/upload/p', 22 'path_b' => '/upload/p',
23 'path_a' => '/upload/m', 23 'path_a' => '/upload/m',
24 ], 24 ],
  25 + //默认
  26 + 'default_b_image' =>[
  27 + 'size' => [
  28 + 'max' => 500 * 1024, // 2M
  29 + ],
  30 + 'path_b' => '/upload/p',
  31 + 'path_a' => '/upload/m',
  32 + ],
25 //默认视频 33 //默认视频
26 'default_file' =>[ 34 'default_file' =>[
27 'size' => [ 35 'size' => [