| 
					
				 | 
			
			
				@@ -10,13 +10,13 @@ namespace app\common\api; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 class UploadApi { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     protected $fileSize = 5 * 1024 * 1024; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    protected $fileExt = "jpg,png,gif,pdf"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    protected $fileMime = "image/jpg,image/png,image/gif,application/pdf"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    protected $fileExt = "jpg,png,gif,pdf,xls,xlsx"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    protected $fileMime = "image/jpg,image/png,image/gif,application/pdf,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public function __construct($config = []) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        $this->fileSize = $config["maxSize"] ?: $this->fileSize; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        $this->fileExt = $config["fileExt"] ?: $this->fileExt; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        $this->fileMime = $config["fileMime"] ?: $this->fileMime; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $this->fileSize = isset($config["maxSize"]) ? $config["maxSize"] : $this->fileSize; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $this->fileExt = isset($config["fileExt"]) ? $config["fileExt"] : $this->fileExt; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $this->fileMime = isset($config["fileMime"]) ? $config["fileMime"] : $this->fileMime; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     /** 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -24,13 +24,13 @@ class UploadApi { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @param type $files 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @return type 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public function uploadList($files) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public function uploadList($files, $path = "uploadfiles") { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            validate(['image' => 'fileSize:' . $this->maxSize . '|fileExt:' . $this->fileExt . '|fileMime:' . $this->fileMime]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            validate(['image' => ["sileSize" => $this->fileSize, "fileExt" => $this->fileExt, "fileMime" => $this->fileMime]]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     ->check($files); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             $savename = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             foreach ($files as $file) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                $savename[] = \think\facade\Filesystem::disk("public")->putFile('topic', $file); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                $savename[] = \think\facade\Filesystem::disk("public")->putFile($path, $file); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return $savename; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } catch (\think\exception\ValidateException $e) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -43,11 +43,11 @@ class UploadApi { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @param type $file 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @return type 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public function uploadOne($file) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public function uploadOne($file, $path = "uploadfiles") { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            validate(['image' => 'fileSize:' . $this->maxSize . '|fileExt:' . $this->fileExt . '|fileMime:' . $this->fileMime]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    ->check($file); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            $savename = \think\facade\Filesystem::disk("public")->putFile('topic', $file); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            validate(['image' => ["sileSize" => $this->fileSize, "fileExt" => $this->fileExt, "fileMime" => $this->fileMime]]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    ->check(["file" => $file]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $savename = \think\facade\Filesystem::disk("public")->putFile($path, $file); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return $savename; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } catch (\think\exception\ValidateException $e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             echo $e->getMessage(); 
			 |