12345678910111213141516171819202122232425262728293031323334353637383940 |
- <?php
- namespace Upload\Lib;
- use Dever;
- class File
- {
- # 获取文件内容
- public function content($file)
- {
- if (strstr($file, '{uploadYun}')) {
- $file = str_replace('{uploadYun}', '', $file);
- } elseif (strstr($file, 'http')) {
- $host = parse_url($file);
- $file = $host['path'];
- }
- $temp = explode('/', $file);
- $key = $temp[1];
- $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);
- }
- }
- return $file;
- }
- }
|