| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 | <?phpnamespace Upload\Lib\Store;use Dever;class Handle{    /**     * __construct     *      * @return mixed     */    public function __construct($data = array())    {        $this->yun = $this->local = false;        $config = Dever::db('upload/upload')->one($data['key']);        $this->save_type = $config['save_type'];        $yun = $config['yun'];        if ($this->save_type >= 2) {            if ($yun == 1) {                $yun = 'Upload\Lib\Store\Qiniu';            }                        $this->yun = new $yun($data);        }        if ($this->save_type <= 3) {            $this->local = new Local($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;        }    }}
 |