|
...
|
...
|
@@ -106,6 +106,7 @@ class FileController |
|
|
|
* @time :2023/6/17 16:32
|
|
|
|
*/
|
|
|
|
public function single(&$files){
|
|
|
|
@file_put_contents(storage_path('logs/lyh_error.log'), var_export(111, true) . PHP_EOL, FILE_APPEND);
|
|
|
|
$hash = hash_file('md5', $files->getPathname());
|
|
|
|
$name = $files->getClientOriginalName();
|
|
|
|
//查看文件是否存在
|
|
...
|
...
|
@@ -122,6 +123,7 @@ class FileController |
|
|
|
$url = $this->config['root'].$this->path;
|
|
|
|
$fileName = uniqid().rand(10000,99999).'.'.$files->getClientOriginalExtension();
|
|
|
|
//同步数据到cos
|
|
|
|
@file_put_contents(storage_path('logs/lyh_error.log'), var_export(222222, true) . PHP_EOL, FILE_APPEND);
|
|
|
|
if($this->upload_location == 1){
|
|
|
|
$cosService = new CosService();
|
|
|
|
$cosService->uploadFile($files,$this->path,$fileName);
|
|
...
|
...
|
@@ -131,6 +133,7 @@ class FileController |
|
|
|
return $this->response($files->getError(), Code::USER_ERROR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@file_put_contents(storage_path('logs/lyh_error.log'), var_export(333, true) . PHP_EOL, FILE_APPEND);
|
|
|
|
$this->saveMysql($fileModel,$files->getSize(),$files->getClientOriginalExtension(),$fileName,$hash,$this->upload_location,$files->getMimeType(),$name);
|
|
|
|
$this->response('资源',Code::SUCCESS,$this->responseData($this->path.'/'.$fileName, $name));
|
|
|
|
}
|
...
|
...
|
|