|  | @@ -15,7 +15,7 @@ class Save
 | 
	
		
			
				|  |  |          8 => 'exe,msi',
 | 
	
		
			
				|  |  |      );
 | 
	
		
			
				|  |  |      private $type = 1;
 | 
	
		
			
				|  |  | -    public function init($id)
 | 
	
		
			
				|  |  | +    public function init($id, $cate_id = 1, $group_id = false, $user_id = false)
 | 
	
		
			
				|  |  |      {
 | 
	
		
			
				|  |  |          $this->config = Dever::db('rule', 'upload')->find($id);
 | 
	
		
			
				|  |  |          if (!$this->config) {
 | 
	
	
		
			
				|  | @@ -25,6 +25,9 @@ class Save
 | 
	
		
			
				|  |  |          if (!$this->config['save']) {
 | 
	
		
			
				|  |  |              Dever::error('存储位置错误');
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        $this->cate_id = $cate_id ? $cate_id : 1;
 | 
	
		
			
				|  |  | +        $this->group_id = $group_id;
 | 
	
		
			
				|  |  | +        $this->user_id = $user_id;
 | 
	
		
			
				|  |  |          return $this;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -52,15 +55,18 @@ class Save
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          $result['type'] = $this->config['save']['type'];
 | 
	
		
			
				|  |  | +        $result['method'] = $this->config['save']['method'];
 | 
	
		
			
				|  |  |          if ($result['type'] > 1) {
 | 
	
		
			
				|  |  |              $result += Dever::load('tool', 'upload')->get($this->config['save'])->getInfo();
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          return $result;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    public function act($id, $source, $default_ext = '', $uid = false, $dest_name = '', $cate = 1)
 | 
	
		
			
				|  |  | +    public function act($source, $default_ext = '', $uid = false, $dest_name = '')
 | 
	
		
			
				|  |  |      {
 | 
	
		
			
				|  |  | -        $this->init($id);
 | 
	
		
			
				|  |  | +        if (!$this->config) {
 | 
	
		
			
				|  |  | +            Dever::error('上传规则错误');
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |          $name = '';
 | 
	
		
			
				|  |  |          $ext = '';
 | 
	
		
			
				|  |  |          $size = 0;
 | 
	
	
		
			
				|  | @@ -157,7 +163,7 @@ class Save
 | 
	
		
			
				|  |  |          $dest = $this->config['id'] . '/' . $this->getDest($name, $ext, $uid);
 | 
	
		
			
				|  |  |          # type 1是文件复制 2是base64 3是远程文件复制
 | 
	
		
			
				|  |  |          $url = Dever::load('tool', 'upload')->get($this->config['save'])->upload($type, $source, $dest, $chunk, $this);
 | 
	
		
			
				|  |  | -        $data = $this->up($source_name, $name, $dest, $this->config['size'], $this->config['width'] ?? 0, $this->config['height'] ?? 0, $cate);
 | 
	
		
			
				|  |  | +        $data = $this->up($source_name, $name, $dest, $this->config['size'], $this->config['width'] ?? 0, $this->config['height'] ?? 0);
 | 
	
		
			
				|  |  |          $data['url'] = $url;
 | 
	
		
			
				|  |  |          $data['type'] = $this->type;
 | 
	
		
			
				|  |  |          if (isset($content)) {
 | 
	
	
		
			
				|  | @@ -180,7 +186,7 @@ class Save
 | 
	
		
			
				|  |  |          return $data;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    private function up($source_name, $name, $dest, $size, $width = 0, $height = 0, $cate = 1)
 | 
	
		
			
				|  |  | +    private function up($source_name, $name, $dest, $size, $width = 0, $height = 0)
 | 
	
		
			
				|  |  |      {
 | 
	
		
			
				|  |  |          $file['rule_id'] = $this->config['id'];
 | 
	
		
			
				|  |  |          $file['name'] = $name;
 | 
	
	
		
			
				|  | @@ -195,7 +201,9 @@ class Save
 | 
	
		
			
				|  |  |          if ($height) {
 | 
	
		
			
				|  |  |              $data['height'] = $height;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        $data['cate_id'] = $cate;
 | 
	
		
			
				|  |  | +        $data['cate_id'] = $this->cate_id;
 | 
	
		
			
				|  |  | +        $data['group_id'] = $this->group_id;
 | 
	
		
			
				|  |  | +        $data['user_id'] = $this->user_id;
 | 
	
		
			
				|  |  |          $data['id'] = Dever::db('file', 'upload')->up($file, $data);
 | 
	
		
			
				|  |  |          return $data;
 | 
	
		
			
				|  |  |      }
 |