作者 lyh

gx

... ... @@ -97,7 +97,7 @@ class FileController
$size = $files->getSize();
$file_type = $files->getClientOriginalExtension();
$mime = $files->getMimeType();
return $this->single($files,$size,$file_type,$mime);
return $this->single($files);
}
}
... ... @@ -108,7 +108,7 @@ class FileController
* @method :post
* @time :2023/6/17 16:32
*/
public function single(&$files,$size,$file_type,$mime = ''){
public function single(&$files){
$hash = hash_file('md5', $files->getPathname());
//查看文件是否存在
$fileModel = new File();
... ... @@ -117,7 +117,7 @@ class FileController
return $this->response('资源',Code::SUCCESS,$this->responseData($file_hash['path']));
}
$url = $this->config['root'].$this->path;
$fileName = uniqid().rand(10000,99999).'.'.$file_type;
$fileName = uniqid().rand(10000,99999).'.'.$files->getClientOriginalExtension();
//同步数据到cos
if($this->upload_location == 1){
$cosService = new CosService();
... ... @@ -128,7 +128,7 @@ class FileController
return $this->response($files->getError(), Code::USER_ERROR);
}
}
$this->saveMysql($fileModel,$size,$file_type,$fileName,$hash,$this->upload_location,$mime);
$this->saveMysql($fileModel,$files->getSize(),$files->getClientOriginalExtension(),$fileName,$hash,$this->upload_location,$files->getMimeType());
return $this->response('资源',Code::SUCCESS,$this->responseData($this->path.'/'.$fileName));
}
... ...