| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 | <?phpnamespace Upload\Lib;use Dever;class File{	# 获取文件内容	public function content($source)	{		if (strstr($source, '{uploadRes}')) {            $source = Dever::local($source);            $content = file_get_contents($source);            return $content;        } elseif (strstr($source, '{uploadYun}')) {            $file = str_replace('{uploadYun}', '', $source);        } elseif (strstr($source, 'http')) {            $host = parse_url($source);            $file = ltrim($host['path'], '/');        }        $temp = explode('/', $file);        $key = $temp[0];        $config = Dever::load('upload/lib/config')->get($key);        if ($config) {            if ($config['save_type'] >= 2 && $config['yun']) {                if ($config['yun']['type'] == 2) {                    $class = 'Upload\Lib\View\Qiniu';                } elseif ($config['yun']['type'] == 1) {                    $class = 'Upload\Lib\View\Oss';                }                $data['host'] = $config['yun']['host'];                                $yun = new $class();                $file = $yun->connect($config['yun'], $config)->download($config['bucket'], $file);            } else {                $file = Dever::local($file);                $file = file_get_contents($file);            }        } else {            $file = Dever::curl($source);        }        return $file;	}}
 |