作者 lyh

gx

@@ -79,13 +79,13 @@ class FileController @@ -79,13 +79,13 @@ class FileController
79 * @time :2023/6/17 16:32 79 * @time :2023/6/17 16:32
80 */ 80 */
81 public function upload() { 81 public function upload() {
  82 + @file_put_contents(storage_path('logs/lyh_error.log'), var_export(1111, true) . PHP_EOL, FILE_APPEND);
82 $this->request->validate([ 83 $this->request->validate([
83 'file'=>['required'], 84 'file'=>['required'],
84 ],[ 85 ],[
85 'file.required'=>'必须填写', 86 'file.required'=>'必须填写',
86 ]); 87 ]);
87 $files = $this->request->file('file'); 88 $files = $this->request->file('file');
88 - @file_put_contents(storage_path('logs/lyh_error.log'), var_export('进入111', true) . PHP_EOL, FILE_APPEND);  
89 if (empty($files)) { 89 if (empty($files)) {
90 $this->response('没有上传的文件!'); 90 $this->response('没有上传的文件!');
91 } 91 }
@@ -94,7 +94,6 @@ class FileController @@ -94,7 +94,6 @@ class FileController
94 if ($type == 'multi') { 94 if ($type == 'multi') {
95 return $this->multi($files); 95 return $this->multi($files);
96 } else { 96 } else {
97 - @file_put_contents(storage_path('logs/lyh_error.log'), var_export('进入333', true) . PHP_EOL, FILE_APPEND);  
98 return $this->single($files); 97 return $this->single($files);
99 } 98 }
100 } 99 }
@@ -107,7 +106,6 @@ class FileController @@ -107,7 +106,6 @@ class FileController
107 * @time :2023/6/17 16:32 106 * @time :2023/6/17 16:32
108 */ 107 */
109 public function single(&$files){ 108 public function single(&$files){
110 - @file_put_contents(storage_path('logs/lyh_error.log'), var_export(111, true) . PHP_EOL, FILE_APPEND);  
111 $hash = hash_file('md5', $files->getPathname()); 109 $hash = hash_file('md5', $files->getPathname());
112 $name = $files->getClientOriginalName(); 110 $name = $files->getClientOriginalName();
113 //查看文件是否存在 111 //查看文件是否存在
@@ -124,7 +122,6 @@ class FileController @@ -124,7 +122,6 @@ class FileController
124 $url = $this->config['root'].$this->path; 122 $url = $this->config['root'].$this->path;
125 $fileName = uniqid().rand(10000,99999).'.'.$files->getClientOriginalExtension(); 123 $fileName = uniqid().rand(10000,99999).'.'.$files->getClientOriginalExtension();
126 //同步数据到cos 124 //同步数据到cos
127 - @file_put_contents(storage_path('logs/lyh_error.log'), var_export(222222, true) . PHP_EOL, FILE_APPEND);  
128 if($this->upload_location == 1){ 125 if($this->upload_location == 1){
129 $cosService = new CosService(); 126 $cosService = new CosService();
130 $cosService->uploadFile($files,$this->path,$fileName); 127 $cosService->uploadFile($files,$this->path,$fileName);
@@ -134,7 +131,6 @@ class FileController @@ -134,7 +131,6 @@ class FileController
134 return $this->response($files->getError(), Code::USER_ERROR); 131 return $this->response($files->getError(), Code::USER_ERROR);
135 } 132 }
136 } 133 }
137 - @file_put_contents(storage_path('logs/lyh_error.log'), var_export(333, true) . PHP_EOL, FILE_APPEND);  
138 $this->saveMysql($fileModel,$files->getSize(),$files->getClientOriginalExtension(),$fileName,$hash,$this->upload_location,$files->getMimeType(),$name); 134 $this->saveMysql($fileModel,$files->getSize(),$files->getClientOriginalExtension(),$fileName,$hash,$this->upload_location,$files->getMimeType(),$name);
139 $this->response('资源',Code::SUCCESS,$this->responseData($this->path.'/'.$fileName, $name)); 135 $this->response('资源',Code::SUCCESS,$this->responseData($this->path.'/'.$fileName, $name));
140 } 136 }