添加后缀
@method addSuf
@since 0.0.1
@param {string|array} $file 文件名
@param {string|array} $size 尺寸
@return {array}
@example \Yii::$app->fileupload->addSuf($file, $suf);
977876
public function addSuf($file, $suf) {
		if(is_array($suf)) {
			$suf = implode('_', $suf);
		}
		if(!empty($file)) {
			if(is_array($file)) {
				foreach($file as $type => $path) {
					$file[$type] = $this->createSuf($path, $suf);
				}
			} else {
				$file = $this->createSuf($file, $suf);
			}
		}

		return $file;
	}
438412
public function upload($file, $format = 'json')
	{
		// Is this "file" a URL?
		$url = filter_var($file, FILTER_VALIDATE_URL) !== false;

		$data = array(
			'key' => $this->key,
			'format' => $format
		);

		if ($url) {
			$data['url'] = $file;
		} else {
			$data['fileupload'] = $file;
		}

		if ($this->credentials) {
			$data['a_username'] = $this->credentials['username'];
			$data['a_password'] = $this->credentials['password'];
		} else if($this->cookie) {
			$data['cookie'] = $this->cookie;
		}

		return $this->post('https://post.imageshack.us/upload_api.php', $data);
	}
909171
public function uploadFrom($file, $type = 'image')
    {
        if (!$file || !$type) {
            $this->setError('参数缺失');

            return false;
        }

        $this->setPostQueryStr('type', $type);

        $name        = 'media'; // 设置上传文件键名 固定为media
        $filename    = $file['name']; // 设置上传文件名
        $filetype    = $file['type'];
        $filecontent = file_get_contents($file['tmp_name']); // 读取临时文件里 上传文件的信息
        $key         = "name=\"{$name}\"; filename=\"{$filename}\"\r\nContent-Type: {$filetype}\r\n"; // curl设置上传文件的一种方法.

        $param       = [];
        $param[$key] = $filecontent;

        $node = 'upload';

        $res = $this->_post($node, $param, false);

        return $res;
    }
1107154
public static function addJsFiles($files = array())
    {
        
		foreach($files as $file){
			self::addFile($file, tao_helpers_Scriptloader::JS);
		}
        
    }
741922
protected function createFromArray($file)
	{
		$file = new SymfonyUploadedFile($file['tmp_name'], $file['name'], $file['type'], $file['size'], $file['error']);

		return $this->createFromObject($file);
	}
885256
private function uploadFile(UploadedFile $file)
    {
        /** @var FileStorage $fileStorage */
        $fileStorage = Yii::$app->get('fileStorage');

        $filename = $fileStorage->saveUploadedFile($file);

        return $fileStorage->put($filename, $file->name);
    }
1238441
private function addFileObject($file)
    {
        $file = $this->getActualFilename($file);

        try
        {
            $this->concatenator->addObject($file, []);
        }
        catch (\Exception $e)
        {
            $this->system->log()->error("Failed to add concatenator object: " . $file);
        }
    }
156093
public function setFile(File $file = null)
    {
        $this->file = $file;

        if (!empty($file)) {
            $size = @getimagesize($file->getPathname());

            if (is_array($size)) {
                list($this->width, $this->height) = $size;
            }

            $this->refreshUpdatedAt();
        }

        return $this;
    }
554139
protected function fileSize($file, $rule)
    {
        if (!($file instanceof File)) {
            return false;
        }
        if (is_array($file)) {
            foreach ($file as $item) {
                if (!$item->checkSize($rule)) {
                    return false;
                }
            }
            return true;
        } else {
            return $file->checkSize($rule);
        }
    }
1171604
public static function upload_file($file, $group, $fsencoding = '') {
        if (empty($file)) {
            return '';
        }
        if ($file['error'] != UPLOAD_ERR_OK) {
            switch ($file['error']) {
                case UPLOAD_ERR_INI_SIZE:
                    throw new Exception('文件超过服务器允许的大小');
                case UPLOAD_ERR_FORM_SIZE:
                    throw new Exception('文件超过表单允许的大小');
                case UPLOAD_ERR_PARTIAL:
                    throw new Exception('文件上传不完整');
                case UPLOAD_ERR_NO_FILE: //未选择文件
                    return '';
                case UPLOAD_ERR_NO_TMP_DIR:
                    throw new Exception('文件上传出错');
                case UPLOAD_ERR_CANT_WRITE:
                    throw new Exception('文件上传出错');
                case UPLOAD_ERR_EXTENSION:
                    throw new Exception('文件上传出错');
                default:
                    throw new Exception('文件上传出错');
            }
        }

        $dirmap = Config::get()->get_config('upload');

        if (!isset($dirmap[$group])) {
            throw new Exception('文件分组错误');
        }

        $allow = $dirmap[$group]['allow'];
        $base_dir = $dirmap[$group]['path'];
        $maxsize = isset($dirmap[$group]['maxsize']) ? intval($dirmap[$group]['maxsize']) : 0;
        $filesize = intval($file['size']);
        if ($maxsize > 0 && $filesize > $maxsize) {
            throw new Exception('文件大小超过限制');
        }

        $pinfo = pathinfo($file['name']);
        $ext = strtolower($pinfo['extension']);

        if (!in_array($ext, $allow)) {
            throw new Exception('不允许的文件类型');
        }
        $name = self::mkname(WEB_ROOT . $base_dir, '.' . $ext, $fsencoding);
        if ($name == '') {
            throw new Exception('同一时间上传的文件过多');
        }
        $dest = WEB_ROOT . $base_dir . '/' . $name;
        $dest = self::conv_to($dest, $fsencoding);
        self::mkdir(dirname($dest));
        if (move_uploaded_file($file['tmp_name'], $dest)) {
            return $base_dir . '/' . $name;
        }
        else {
            throw new Exception('文件移动出错');
        }
    }
221395
public function add_stored_file($file) {
        if (is_numeric($file)) {
            $this->files[$file] = $file;
        } else {
            $this->files[$file->get_id()] = $file;
        }
    }
947903
private function upload($file)
    {
        $file = $this->model->createFile($this->attribute, $file->tempName, $file->name);
        if ($file) {
            if ($this->saveAfterUpload) {
                $this->model->save(false);
            }
            $presetAfterUpload = $this->model->filePresetAfterUpload($this->attribute);
            if (count($presetAfterUpload)) {
                $this->applyPreset($presetAfterUpload, $file);
            }
            $template = $this->model->fileOption($this->attribute, 'template');
            if ($template) {
                return $this->response(
                    $this->controller->renderFile(Yii::getAlias($template), [
                        'file' => $file,
                        'model' => $this->model,
                        'attribute' => $this->attribute
                    ])
                );
            }
            return $this->response([
                $this->resultFieldId => $file->getPrimaryKey(),
                $this->resultFieldPath => $this->model->fileUrl($this->attribute, $file),
            ]);
        }
        return $this->response(['error' => Yii::t('filemanager-yii2', 'Error saving file')]); // @codeCoverageIgnore
    }
775468
public static function createUploadedFile(
        $file,
        $size = null,
        $error = UPLOAD_ERR_OK,
        $clientFilename = null,
        $clientMediaType = null
    ) {
        if (! static::$uploadedFileFactory) {
            static::$uploadedFileFactory = new UploadedFileFactory();
        }

        return static::$uploadedFileFactory->createUploadedFile(
            $file,
            $size,
            $error,
            $clientFilename,
            $clientMediaType
        );
    }
672435
function addFile(file) {
                var $li = $('<li id="' + file.id + '">' +
                        '<p class="title">' + file.name + '</p>' +
                        '<p class="imgWrap"></p>' +
                        '<p class="progress"><span></span></p>' +
                        '</li>'),

                    $btns = $('<div class="file-panel">' +
                        '<span class="cancel">' + lang.uploadDelete + '</span>' +
                        '<span class="rotateRight">' + lang.uploadTurnRight + '</span>' +
                        '<span class="rotateLeft">' + lang.uploadTurnLeft + '</span></div>').appendTo($li),
                    $prgress = $li.find('p.progress span'),
                    $wrap = $li.find('p.imgWrap'),
                    $info = $('<p class="error"></p>').hide().appendTo($li),

                    showError = function (code) {
                        switch (code) {
                            case 'exceed_size':
                                text = lang.errorExceedSize;
                                break;
                            case 'interrupt':
                                text = lang.errorInterrupt;
                                break;
                            case 'http':
                                text = lang.errorHttp;
                                break;
                            case 'not_allow_type':
                                text = lang.errorFileType;
                                break;
                            default:
                                text = lang.errorUploadRetry;
                                break;
                        }
                        $info.text(text).show();
                    };

                if (file.getStatus() === 'invalid') {
                    showError(file.statusText);
                } else {
                    $wrap.text(lang.uploadPreview);
                    if ('|png|jpg|jpeg|bmp|gif|'.indexOf('|'+file.ext.toLowerCase()+'|') == -1) {
                        $wrap.empty().addClass('notimage').append('<i class="file-preview file-type-' + file.ext.toLowerCase() + '"></i>' +
                            '<span class="file-title">' + file.name + '</span>');
                    } else {
                        if (browser.ie && browser.version <= 7) {
                            $wrap.text(lang.uploadNoPreview);
                        } else {
                            uploader.makeThumb(file, function (error, src) {
                                if (error || !src || (/^data:/.test(src) && browser.ie && browser.version <= 7)) {
                                    $wrap.text(lang.uploadNoPreview);
                                } else {
                                    var $img = $('<img src="' + src + '">');
                                    $wrap.empty().append($img);
                                    $img.on('error', function () {
                                        $wrap.text(lang.uploadNoPreview);
                                    });
                                }
                            }, thumbnailWidth, thumbnailHeight);
                        }
                    }
                    percentages[ file.id ] = [ file.size, 0 ];
                    file.rotation = 0;

                    /* 检查文件格式 */
                    if (!file.ext || acceptExtensions.indexOf(file.ext.toLowerCase()) == -1) {
                        showError('not_allow_type');
                        uploader.removeFile(file);
                    }
                }

                file.on('statuschange', function (cur, prev) {
                    if (prev === 'progress') {
                        $prgress.hide().width(0);
                    } else if (prev === 'queued') {
                        $li.off('mouseenter mouseleave');
                        $btns.remove();
                    }
                    // 成功
                    if (cur === 'error' || cur === 'invalid') {
                        showError(file.statusText);
                        percentages[ file.id ][ 1 ] = 1;
                    } else if (cur === 'interrupt') {
                        showError('interrupt');
                    } else if (cur === 'queued') {
                        percentages[ file.id ][ 1 ] = 0;
                    } else if (cur === 'progress') {
                        $info.hide();
                        $prgress.css('display', 'block');
                    } else if (cur === 'complete') {
                    }

                    $li.removeClass('state-' + prev).addClass('state-' + cur);
                });

                $li.on('mouseenter', function () {
                    $btns.stop().animate({height: 30});
                });
                $li.on('mouseleave', function () {
                    $btns.stop().animate({height: 0});
                });

                $btns.on('click', 'span', function () {
                    var index = $(this).index(),
                        deg;

                    switch (index) {
                        case 0:
                            uploader.removeFile(file);
                            return;
                        case 1:
                            file.rotation += 90;
                            break;
                        case 2:
                            file.rotation -= 90;
                            break;
                    }

                    if (supportTransition) {
                        deg = 'rotate(' + file.rotation + 'deg)';
                        $wrap.css({
                            '-webkit-transform': deg,
                            '-mos-transform': deg,
                            '-o-transform': deg,
                            'transform': deg
                        });
                    } else {
                        $wrap.css('filter', 'progid:DXImageTransform.Microsoft.BasicImage(rotation=' + (~~((file.rotation / 90) % 4 + 4) % 4) + ')');
                    }

                });

                $li.insertBefore($filePickerBlock);
            }
257670
public function universalizeUpload($file)
    {
        if ((is_string($file) && is_file($file)) || $file instanceof File) {
            return $file;
        }

        return $this->getUploadedFlyFile($file);
    }
115168
public function addColumn(Column $column = null, string $size = ''): Column
    {
        if (!$column) {
            $column = new Column();
        }

        $this->columns[$size][] = $column;

        return $column;
    }
1060764
public function uploadQiniu($file)
    {
        $info = [
            'success' => 1,
            'message' => '上传成功',
            'url' => '',
        ];

        $filename = $this->getFilename($file);

        $auth = new Auth($this->qiniuAccessKey, $this->qiniuSecretKey);
        $token = $auth->uploadToken($this->qiniuBucket);

        $upManager = new UploadManager();

        list($code, $error) = $upManager->putFile($token, $filename, $file);

        if ($error) {
            $info['success'] = 0;
            $info['message'] = $error->message();
            return $info;
        }

        $info['url'] = $this->qiniuDomain . DIRECTORY_SEPARATOR . $filename;
        return $info;
    }