正在显示
1 个修改的文件
包含
4 行增加
和
4 行删除
| @@ -97,7 +97,7 @@ class FileController | @@ -97,7 +97,7 @@ class FileController | ||
| 97 | $size = $files->getSize(); | 97 | $size = $files->getSize(); |
| 98 | $file_type = $files->getClientOriginalExtension(); | 98 | $file_type = $files->getClientOriginalExtension(); |
| 99 | $mime = $files->getMimeType(); | 99 | $mime = $files->getMimeType(); |
| 100 | - return $this->single($files,$size,$file_type,$mime); | 100 | + return $this->single($files); |
| 101 | } | 101 | } |
| 102 | } | 102 | } |
| 103 | 103 | ||
| @@ -108,7 +108,7 @@ class FileController | @@ -108,7 +108,7 @@ class FileController | ||
| 108 | * @method :post | 108 | * @method :post |
| 109 | * @time :2023/6/17 16:32 | 109 | * @time :2023/6/17 16:32 |
| 110 | */ | 110 | */ |
| 111 | - public function single(&$files,$size,$file_type,$mime = ''){ | 111 | + public function single(&$files){ |
| 112 | $hash = hash_file('md5', $files->getPathname()); | 112 | $hash = hash_file('md5', $files->getPathname()); |
| 113 | //查看文件是否存在 | 113 | //查看文件是否存在 |
| 114 | $fileModel = new File(); | 114 | $fileModel = new File(); |
| @@ -117,7 +117,7 @@ class FileController | @@ -117,7 +117,7 @@ class FileController | ||
| 117 | return $this->response('资源',Code::SUCCESS,$this->responseData($file_hash['path'])); | 117 | return $this->response('资源',Code::SUCCESS,$this->responseData($file_hash['path'])); |
| 118 | } | 118 | } |
| 119 | $url = $this->config['root'].$this->path; | 119 | $url = $this->config['root'].$this->path; |
| 120 | - $fileName = uniqid().rand(10000,99999).'.'.$file_type; | 120 | + $fileName = uniqid().rand(10000,99999).'.'.$files->getClientOriginalExtension(); |
| 121 | //同步数据到cos | 121 | //同步数据到cos |
| 122 | if($this->upload_location == 1){ | 122 | if($this->upload_location == 1){ |
| 123 | $cosService = new CosService(); | 123 | $cosService = new CosService(); |
| @@ -128,7 +128,7 @@ class FileController | @@ -128,7 +128,7 @@ class FileController | ||
| 128 | return $this->response($files->getError(), Code::USER_ERROR); | 128 | return $this->response($files->getError(), Code::USER_ERROR); |
| 129 | } | 129 | } |
| 130 | } | 130 | } |
| 131 | - $this->saveMysql($fileModel,$size,$file_type,$fileName,$hash,$this->upload_location,$mime); | 131 | + $this->saveMysql($fileModel,$files->getSize(),$files->getClientOriginalExtension(),$fileName,$hash,$this->upload_location,$files->getMimeType()); |
| 132 | return $this->response('资源',Code::SUCCESS,$this->responseData($this->path.'/'.$fileName)); | 132 | return $this->response('资源',Code::SUCCESS,$this->responseData($this->path.'/'.$fileName)); |
| 133 | } | 133 | } |
| 134 | 134 |
-
请 注册 或 登录 后发表评论