正在显示
1 个修改的文件
包含
6 行增加
和
3 行删除
| @@ -318,8 +318,8 @@ class ImageController extends Controller | @@ -318,8 +318,8 @@ class ImageController extends Controller | ||
| 318 | private function multi(&$files) { | 318 | private function multi(&$files) { |
| 319 | $data = []; | 319 | $data = []; |
| 320 | foreach ($files as $file) { | 320 | foreach ($files as $file) { |
| 321 | + try { | ||
| 321 | $hash = hash_file('sha256', $file->getPathname()); | 322 | $hash = hash_file('sha256', $file->getPathname()); |
| 322 | - $name = $file->getClientOriginalName(); | ||
| 323 | $imageModel = new ImageModel(); | 323 | $imageModel = new ImageModel(); |
| 324 | //查看图片是否已上传 | 324 | //查看图片是否已上传 |
| 325 | $param = ['hash'=>$hash,'refer'=>$this->param['refer'] ?? 0,'is_cos'=>(($this->upload_location == 0) ? 1 : 0)]; | 325 | $param = ['hash'=>$hash,'refer'=>$this->param['refer'] ?? 0,'is_cos'=>(($this->upload_location == 0) ? 1 : 0)]; |
| @@ -331,8 +331,9 @@ class ImageController extends Controller | @@ -331,8 +331,9 @@ class ImageController extends Controller | ||
| 331 | $data[] = $this->responseData($image_hash['path'],$image_hash['name']); | 331 | $data[] = $this->responseData($image_hash['path'],$image_hash['name']); |
| 332 | continue; | 332 | continue; |
| 333 | } | 333 | } |
| 334 | - $image_type = $file->getClientOriginalExtension(); | 334 | + $name = $file->getClientOriginalName(); |
| 335 | $fileName = $this->getOnlyFilename($name,$param['project_id'] ?? 0); | 335 | $fileName = $this->getOnlyFilename($name,$param['project_id'] ?? 0); |
| 336 | + $image_type = $file->getClientOriginalExtension(); | ||
| 336 | $this->saveMysql($imageModel,$file->getSize(),$image_type,$fileName,$hash,$this->upload_location,$file->getMimeType(),$name); | 337 | $this->saveMysql($imageModel,$file->getSize(),$image_type,$fileName,$hash,$this->upload_location,$file->getMimeType(),$name); |
| 337 | //同步数据到cos | 338 | //同步数据到cos |
| 338 | if($this->upload_location == 0){ | 339 | if($this->upload_location == 0){ |
| @@ -345,7 +346,9 @@ class ImageController extends Controller | @@ -345,7 +346,9 @@ class ImageController extends Controller | ||
| 345 | } | 346 | } |
| 346 | $this->synchronizationImage($fileName,$this->upload_location); | 347 | $this->synchronizationImage($fileName,$this->upload_location); |
| 347 | $data[] = $this->responseData($this->path.'/'.$fileName,$name); | 348 | $data[] = $this->responseData($this->path.'/'.$fileName,$name); |
| 348 | - $hash = $name = ''; | 349 | + }catch (\Exception $e){ |
| 350 | + $this->response('图片资源',Code::SUCCESS,$data); | ||
| 351 | + } | ||
| 349 | } | 352 | } |
| 350 | $this->response('图片资源',Code::SUCCESS,$data); | 353 | $this->response('图片资源',Code::SUCCESS,$data); |
| 351 | } | 354 | } |
-
请 注册 或 登录 后发表评论