yun = $this->local = false; $config = Dever::load('upload/lib/config')->get($data['key']); //$config = Dever::db('upload/upload')->one($data['key']); if (!$config) { Dever::alert('错误的上传配置'); return; } if (isset($data['yun']) && $data['yun']) { $config['save_type'] = 4; $config['yun'] = $data['yun']; } $this->save_type = $config['save_type']; if ($this->save_type >= 2 && $config['yun']) { if ($config['yun']['type'] == 2) { $class = 'Upload\Lib\Store\Qiniu'; } elseif ($config['yun']['type'] == 1) { $class = 'Upload\Lib\Store\Oss'; } elseif ($config['yun']['type'] == 3) { $class = 'Upload\Lib\Store\Sina'; } $data['host'] = $config['yun']['host']; $this->yun = new $class($config, $data); } if ($this->save_type <= 3) { $this->local = new Local($config, $data); } } # 复制文件到服务器上 public function copy() { return $this->get(); } # 获取文件名 public function name() { return $this->get('getName'); } # 手动裁图 public function cropper() { if ($this->local) { $this->local->cropper(); } if ($this->yun) { $this->yun->cropper(); } } # 获取文件名 public function get($type = 'copy') { $yun = $local = array(); if ($this->save_type <= 3) { $local = $this->local->$type(); } if ($local && $local['status'] == -1) { return $local; } if ($this->save_type >= 2) { $yun = $this->yun->$type(); } if ($type == 'copy') { if ($this->local) { $this->local->delete(); } elseif ($this->yun) { $this->yun->delete(); } } if ($this->save_type <= 2) { return $local; } elseif ($this->save_type > 2) { return $yun; } } public function handle_t($id, $source, $dest, $path) { $yun = $local = array(); if ($this->save_type <= 3) { $local = $this->local->handle_t($id, $source, $dest); } if ($local) { return $local; } if ($this->save_type >= 2) { $yun = $this->yun->handle_t($id, $source, $dest, $path); } if ($this->save_type <= 2) { return $local; } elseif ($this->save_type > 2) { return $yun; } } public function handle_c($id, $source, $dest, $path) { $yun = $local = array(); if ($this->save_type <= 3) { $local = $this->local->handle_c($id, $source, $dest); } if ($local) { return $local; } if ($this->save_type >= 2) { $yun = $this->yun->handle_c($id, $source, $dest, $path); } if ($this->save_type <= 2) { return $local; } elseif ($this->save_type > 2) { return $yun; } } }