PHPackages                             juckzhang/yii2-upload - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. juckzhang/yii2-upload

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

juckzhang/yii2-upload
=====================

The Qiniu 、ftp、local、aliyun-oss integration for the Yii2 framework

1.0.0(9y ago)2141BSD-3-ClausePHPPHP &gt;=5.4.0

Since Apr 17Pushed 9y ago1 watchersCompare

[ Source](https://github.com/juckzhang/yii2-upload)[ Packagist](https://packagist.org/packages/juckzhang/yii2-upload)[ RSS](/packages/juckzhang-yii2-upload/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (7)Versions (2)Used By (0)

Qiniu Ftp AliYun Extension for Yii2
===================================

[](#qiniu-ftp-aliyun-extension-for-yii2)

The Qiniu integration for the Yii framework

[![Latest Stable Version](https://camo.githubusercontent.com/e7479100f1da88a018688c5b38b128d2dfe6bee5347f405df9efd517c755d2b8/68747470733a2f2f706f7365722e707567782e6f72672f6a75636b7a68616e672f796969322d75706c6f61642f76657273696f6e)](https://packagist.org/packages/juckzhang/yii2-upload)[![Total Downloads](https://camo.githubusercontent.com/51ca386285659016e777d71bf502c81e048ecd2f38b5a0702b808b62ca4ac9a2/68747470733a2f2f706f7365722e707567782e6f72672f6a75636b7a68616e672f796969322d75706c6f61642f646f776e6c6f616473)](https://packagist.org/packages/juckzhang/yii2-upload)[![License](https://camo.githubusercontent.com/5e7c35ff73f21e3d2b729d6d0bba288a9928de69dc5577cbdd6090efffa4dce4/68747470733a2f2f706f7365722e707567782e6f72672f6a75636b7a68616e672f796969322d75706c6f61642f6c6963656e7365)](https://packagist.org/packages/juckzhang/yii2-upload)

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
composer require juckzhang/yii2-upload:*

```

or add

```
"juckzhang/yii2-upload": "*"
```

to the `require` section of your composer.json.

Configuration
-------------

[](#configuration)

To use this extension, simply add the following code in your application configuration:

#### \[配置\]

[](#配置)

1、config目录下新添加上传配置文件upload.php

```
return [
    'advertisement' => [
        'extensions' => null,
        'mimeTypes'  => null,
        'minSize' => 1024,
        'maxSize' => 10 * 1048576,
        'uploadRequired' => '上传文件不存在!',
        'tooBig'  => '文件大小超过限制',
        'tooSmall' => '上传文件太小',
        'tooMany' => '上传文件数量超过限制',
        'wrongExtension' => '文件扩展名不支持',
        'wrongMimeType' => '文件mime-type不支持',
        'path'  => realpath(__DIR__ . '/../upload'),
        'urlPrefix'   => 'http://localhost',
        'remoteUpload' => true,
        'recursive' => false,
    ],
];
```

2、

```
/** QiNiu **/
return [
    'components' => [
      'uploadTool' => [
          'class' => 'juckzhang\drivers\UploadTool',
           'handler' => [
               'class' => 'juckzhang\drivers\UploadQiNiu',
               'diskName' => 'privateBucket',
               'config' => [
               'class' => 'dcb9\qiniu\Component',
               'accessKey' => 'YOUR ACCESSKEY',
               'secretKey' => 'YOUR SECRETKEY',
               'disks' => [
                   'privateBucket' => [
                       'bucket' => 'YOUR BUCKET',
                       'baseUrl' => 'http://your-domain/',
                       'isPrivate' => true,
                       'zone' => 'zone1', // 可设置为 zone0, zone1 @see \Qiniu\Zone
                   ],
               ],
           ],
      ],
    ],
]

/** OR AliYun **/
return [
    'components' => [
      'uploadTool' => [
          'class' => 'juckzhang\drivers\UploadTool',
          'handler' => [
              'class' => 'juckzhang\drivers\UploadAliYun',
              'accessKeyId' => 'YOUR ACCESSSKEYID',
              'accessKeySecret' => 'ACCESSKEYSECRET',
              'bucket' => 'test-zaizaitv-upload',
              'endPoint' => 'http://your-domain/',
          ],
      ],
    ],
]

/** OR Ftp **/
return [
    'components' => [
      'uploadTool' => [
          'class' => 'juckzhang\drivers\UploadTool',
          'handler' => [
              'class' => 'juckzhang\drivers\UploadFtp',
              'config' => [
                  'class' => 'gftp\FtpComponent',
                  'connectionString' => 'ftp://USERNAME:PASSWORD@HOST:PORT',
                  'driverOptions' => [
                      'timeout' => 30,
                  ],
              ],
          ],
      ],
    ],
  ]
```

#### \[使用1\]

[](#使用1)

```
\Yii::$app->get('uploadTool')->uploadFile($remoteFileName,$localFileName);
```

#### \[使用2\]

[](#使用2)

```
/**单文件上传**/
juckzhang\UploadService::getService()->upload($sceneType);

/**多文件上传**/
juckzhang\UploadService::getService()->multiUpload($sceneType);
```

#### \[控制器中使用\]

[](#控制器中使用)

```
    'controllerMap' => [
        'upload' => [
            'class' => 'juckzhang\controllers\UploadController',
        ],
    ],
```

Tricks
------

[](#tricks)

- 给配置的组件加 IDE 自动补全 [IDE autocompletion for custom components](https://github.com/samdark/yii2-cookbook/blob/master/book/ide-autocompletion.md)

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3361d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/13914413?v=4)[marmot](/maintainers/juckzhang)[@juckzhang](https://github.com/juckzhang)

---

Top Contributors

[![juckzhang](https://avatars.githubusercontent.com/u/13914413?v=4)](https://github.com/juckzhang "juckzhang (10 commits)")

---

Tags

ftphelperyii2qiniualiyun-ossjuckzhang

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/juckzhang-yii2-upload/health.svg)

```
[![Health](https://phpackages.com/badges/juckzhang-yii2-upload/health.svg)](https://phpackages.com/packages/juckzhang-yii2-upload)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
