根据FILE上传

@param array $file
@param string $type
@param array $option
@return array
198113
public function uploadByFile($file, $type = '', $option = [])
    {
        if ($file['error'] > 0) {
            switch ($file['error']) {
                case 1:
                    $info = '文件超过服务器允许上传的大小';
                    break;
                case 2:
                    $info = '文件超过表单允许上传的大小';
                    break;
                case 3:
                    $info = '文件只有部分被上传';
                    break;
                case 4:
                    $info = '没有找到要上传的文件';
                    break;
                case 5:
                    $info = '服务器临时文件夹丢失';
                    break;
                case 6:
                    $info = '没有找到临时文件夹';
                    break;
                case 7:
                    $info = '写入临时文件失败';
                    break;
                case 8:
                    $info = 'PHP不允许上传文件';
                    break;
                default:
                    $info = '未知的上传错误';
                    break;
            }
            return Format::formatResult(0, $info);
        } else {
            $option['mime'] = $file['type'];
            return self::uploadByPath($file['tmp_name'], $type, $option);
        }
    }
590468
public function put($file, $content, array $option = [])
    {
        if (isset($option['bucket'])) {
            $bucket = $option['bucket'];
        } else {
            $bucket = $this->config['bucket'];
        }

        $this->client->putObject(array(
            'Bucket' => $bucket,
            'Key'    => $file,
            'Body'   => $content
        ));
    }
435999
public function checkRequest($type, $file)
    {
        // no checks for getters
        if(in_array($type, ['detectors', 'mime-types', 'parsers', 'version']))
        {
            //
        }
        // invalid local file
        elseif(!preg_match('/^http/', $file) && !file_exists($file))
        {
            throw new Exception("File $file can't be opened");
        }
        // invalid remote file
        elseif(preg_match('/^http/', $file) && !preg_match('/200/', get_headers($file)[0]))
        {
            throw new Exception("File $file can't be opened", 2);
        }
        // download remote file if required only for integrated downloader
        elseif(preg_match('/^http/', $file) && $this->downloadRemote)
        {
            $file = $this->downloadFile($file);
        }

        return $file;
    }
1339069
public function get_file($file, $type, $folder = '')
	{
		if ($file = $this->find_file($file, $type, $folder))
		{
			return $this->_asset_url.$file;
		}

		return false;
	}
970727
private function _saveBBoxRecord($file, $type)
    {
        fwrite($file, Util::packDouble(
            isset($this->boundingBox[$type]) ? $this->boundingBox[$type] : 0
        ));
    }
351848
public static function create( $file, $type = null ) 
	{
		// when no type is given use the file extension
		if ( is_null( $type ) ) 
		{
			$type = CCStr::extension( $file );

			// validate type
			if ( !in_array( $type, static::$available_image_types ) )
			{
				$type = null;
			}
		}

		$image_data = getimagesize( $file );

		if ( $image_data === false ) 
		{
			return false;
		}

		$image = null;

		switch( $image_data['mime'] ) 
		{
			case 'image/gif':
				$image = imagecreatefromgif( $file );
			break;

			case 'image/jpeg';
				$image = imagecreatefromjpeg( $file );
			break;

			case 'image/png':
				$image = imagecreatefrompng( $file );
			break;

			default:
				// we dont support other image types
				return false;
			break;
		}

		// when the image type is still null we are going to use 
		// the mime type of the image 
		if ( is_null( $type ) )
		{
			$type = CCStr::suffix( $image_data['mime'], '/' );
		}

		return new static( $image, $type );
	}
1260564
public function xSendFile($file, $options = array())
    {
        Yii::app()->request->xSendFile($file->resolvePath(), $options);
    }
722138
public function getFileType($ext, $type = '')
    {
        // 可上传类型
        $upload_type = $this->getUploadType();
        
        // 没有指定上传类型
        if ($type == '') {
            foreach ($upload_type as $c => $v) {
                if (in_array($ext, $v)) {
                    $type = $c;
                    break;
                }
            }
        }
        
        // 验证上传类型
        if ($type == '' || ! isset($upload_type[$type]) || ! in_array($ext, $upload_type[$type])) {
            return '';
        } else {
            return $type;
        }
    }
759183
public static function create($option = [], $type = self::TYPE_LOCAL)
    {
        $class_name = '\\cms\\upload\\driver\\' . ucfirst($type) . 'Upload';
        if (class_exists($class_name)) {
            try {
                return $class_name::instance($option);
            } catch (\Exception $e) {}
        }
    }
1321217
public function store(UploadFile $file, $location = null, array $option = [])
    {
        $content = $file->getContent();
        $stream = fopen('php://temp', 'w+b');

        fwrite($stream, $content);
        rewind($stream);

        $result = $this->writeStream($location, $stream, $option);
        fclose($stream);

        if ($result === false) {
            return false;
        }

        $result['content'] = $content;

        return $result;
    }
322143
public static function require(String $file, String $type = 'require')
    {
        $file = Info::rpath($file);

        if( ! is_file($file) )
        {
            throw new Exception\FileNotFoundException(NULL, $file);
        }

        switch( $type )
        {
            case 'require'     : return require      $file;
            case 'require_once': return require_once $file;
            case 'include'     : return include      $file;
            case 'include_once': return include_once $file;
        }
    }
1228503
public function compress($type, $files, $file) 
	{
		// files have been updated so update the minified file
		if($this->isUpdated($files))
		{
			$content = $this->getFileContents($files);
			switch($type){
				case 'css':
					$content = $this->minifyCSS($content);
				break;
				case 'js':
					$content = $this->minifyJS($content);
				break;
			}
			$this->saveFile($file, $content);
		}
		return str_replace($this->scriptPath,$this->coreUrl,$file);	
	}
1304327
public function store(UploadFile $file, $location = null, array $option = [])
    {
        if (is_array($location)) {
            $option = $location;
            $location = null;
        }

        if (isset($option['as'])) {
            $filename = $option['as'];
        } else {
            $filename = $file->getHashName();
        }

        if (is_null($location)) {
            $location = $filename;
        } else {
            $location = trim($location, '/') . '/' . $filename;
        }

        return $this->put($location, $file->getContent());
    }
756636
protected function loadFile(string $file, array $options)
    {
        $json = file_get_contents($file);
        
        return json_decode($json, false, 512, JSON_BIGINT_AS_STRING);
    }
375359
public function request($type, $file = null)
    {
        // check if not checked
        $this->check();

        // check if is cached
        if(isset($this->cache[sha1($file)][$type]))
        {
            return $this->cache[sha1($file)][$type];
        }

        // command arguments
        $arguments = $this->getArguments($type, $file);

        // check the request
        $file = parent::checkRequest($type, $file);

        // add last argument
        if($file)
        {
            $arguments[] = escapeshellarg($file);
        }

        // build command
        $jar = escapeshellarg($this->path);
        $command = ($this->java ?: 'java') . " -jar $jar " . implode(' ', $arguments);

        // run command
        $response = $this->exec($command);

        // metadata response
        if($type == 'meta')
        {
            // fix for invalid? json returned only with images
            $response = str_replace(basename($file) . '"}{', '", ', $response);

            // on Windows, response comes in another charset
            if(defined('PHP_WINDOWS_VERSION_MAJOR'))
            {
                $response = utf8_encode($response);
            }

            $response = Metadata::make($response, $file);
        }

        // cache certain responses
        if(in_array($type, ['lang', 'meta']))
        {
            $this->cache[sha1($file)][$type] = $response;
        }

        return $response;
    }
593922
public function upload($file, array $options = [])
    {
        $filename = sprintf('%s-%s', rand(100, 999), $file->getClientOriginalName());
        return Storage::putFileAs($this->uploadFolder, $file, $filename);
    }
1354268
public UploadMediaResponse uploadMedia(MediaType type, File file) {
        UploadMediaResponse response;
        String url = "http://file.api.weixin.qq.com/cgi-bin/media/upload?access_token=#&type=" + type.toString();
        BaseResponse r = executePost(url, null, file);
        response = JSONUtil.toBean(r.getErrmsg(), UploadMediaResponse.class);
        return response;
    }