PHPackages                             yiicod/yii2-fileupload - 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. [File &amp; Storage](/categories/file-storage)
4. /
5. yiicod/yii2-fileupload

ActiveYii2-extension[File &amp; Storage](/categories/file-storage)

yiicod/yii2-fileupload
======================

File uploader based on the jQuery-File-Upload for the Yii framework

71.0kPHP

Since Nov 3Pushed 7y ago1 watchersCompare

[ Source](https://github.com/yiicod/yii2-fileupload)[ Packagist](https://packagist.org/packages/yiicod/yii2-fileupload)[ RSS](/packages/yiicod-yii2-fileupload/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Yii File uploader based on blueimp jquery-file-upload
=====================================================

[](#yii-file-uploader-based-on-blueimp-jquery-file-upload)

[![Latest Stable Version](https://camo.githubusercontent.com/6cdcd99780302c2bc537e0d01304efb2d3f47575e758583e5d89399f209d107f/68747470733a2f2f706f7365722e707567782e6f72672f796969636f642f796969322d66696c6575706c6f61642f762f737461626c65)](https://packagist.org/packages/yiicod/yii2-fileupload) [![Total Downloads](https://camo.githubusercontent.com/85244b322ad984a59ceef9f60cc08d0d612e7b3e961bbed3c0e3889416425660/68747470733a2f2f706f7365722e707567782e6f72672f796969636f642f796969322d66696c6575706c6f61642f646f776e6c6f616473)](https://packagist.org/packages/yiicod/yii2-fileupload) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/e956a1952822b031ec6816b3d1e5dc939489c3176e4c7388f0995380dc53a7a7/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f796969636f642f796969322d66696c6575706c6f61642f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/yiicod/yii2-fileupload/?branch=master)[![Code Climate](https://camo.githubusercontent.com/0b2f0bf56fd0d8b17ae708fa1f08ee2fceff0d868f037a22b7a19bdb4e56e320/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f796969636f642f796969322d66696c6575706c6f61642f6261646765732f6770612e737667)](https://codeclimate.com/github/yiicod/yii2-fileupload)

File uploader base on blueimp jquery-file-upload. You can write easy themes for uploader. This extension provide you all workflow for upload files on your server.

#### Install:

[](#install)

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

Either run

```
php composer.phar require --prefer-dist yiicod/yii2-fileupload "*"

```

or add

```
"yiicod/yii2-fileupload": "*"
```

to the require section of your composer.json.

#### Config

[](#config)

Set to controller

```
public function actions()
{
    return array(
        'fileUpload' => [
            'class' => 'yiicod\fileupload\actions\FileUploadAction',
        ],
    );
}
```

Add behavior for model

```
public function behaviors()
{
    return [
        'FileUploadBehavior' => [
            'class' => 'yiicod\fileupload\models\behaviors\FileUploadBehavior',
            'sourceRepositoryClass' => [
                'class' => SourceRepository::class,
                'uploadDir' => Yii::getAlias('@webroot/uploads'), // Base dir for file
                'uploadUrl' => '/uploads', // Base url to folder
            ],
            'fields' => array('logo'),
        ],
    ];
}
```

#### Usage

[](#usage)

```
FileUploadWidget::widget([
    'id' => 'fileuploader',
    'model' => Model::class,
    'attribute' => 'modelAttribute',
    'allowedExtensions' => array('jpeg', 'jpg', 'gif', 'png'),
    'maxFileSize' => 2 * 1024 * 1024, // limit in server-side and in client-side 2mb
    'uploadDir' => Yii::getPathOfAlias('@webroot/uploads/temp'), // temp base dir
    'uploadUrl' => Yii::$app->getBaseUrl(true) . '/uploads/temp/', // temp base url
    'uploader' => UserAvatar::class,
    'userData' => [], // Any data for UploaderInterface
    'maxUploads' => -1, // defaults to -1 (unlimited)
    'theme' => [
        'class' => BaseTheme::class, //Implements yiicod\fileupload\base\ThemeInterface
        'multiple' => false, // allow to add multiple file uploads
        'buttonText' => 'Upload file',
        'dropFilesText' => 'Upload or Drop here',
        'clientOptions' => array(
            //For chunk uploded
            'maxChunkSize' => 10000000
        ),
    ],
    'options' => [],
    'defaultUrl' => 'site/fileUpload',
]);
```

Then add uploader, which extends yiicod\\fileupload\\base\\UploaderInterface and provides functionality to handle uploaded file

#### Upload immediately

[](#upload-immediately)

```
class UserAvatar implement UploaderInterface {
    /**
     * Event for coco uploader
     * @param string $fullFileName Full file path
     * @param Array $userdata Userdata from widget
     * @param Array $results Uploaded result file
     * @return Array or null
     */
    public function uploading($fullFileName, $userdata, $results)
    {
        $model = new UserModel();
        //Save to temp
        $model->onAfterFileUploaded($fullFileName, 'logo');

        //After save requered set
        if ($model->save()) {
                return [
                    'url' => $model->getFileSrc('logo'),
                    '...' => '...'
                ];
            )else{
                //Delete temp uploaded file
                $model->resetFile('logo');
                return [
                    'error' => 'Insert error message'
                    '...' => '...'
                ];
            };
        }
    }
}
```

#### Upload on submit

[](#upload-on-submit)

```
class UserAvatar implement UploaderInterface{

    /**
     * Event for coco uploader
     * @param string $fullFileName Full file path
     * @param Array $userdata Userdata from widget
     * @param Array $results Uploaded result file
     * @return Array or null
     */
    public function uploading($fullFileName, $userdata, $results)
    {
        $model = new UserModel();
        //Save to temp
        $model->onAfterFileUploaded($fullFileName, 'logo');
    }
}
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/7934283ca98b7f31bb5bf13119a8495cad80ac9097125a48792f47caddb588b9?d=identicon)[lexxorlov](/maintainers/lexxorlov)

---

Top Contributors

[![lexxorlov](https://avatars.githubusercontent.com/u/7910574?v=4)](https://github.com/lexxorlov "lexxorlov (13 commits)")

---

Tags

blueimp-jqueryphpuploaderyii2yii2-extension

### Embed Badge

![Health badge](/badges/yiicod-yii2-fileupload/health.svg)

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

###  Alternatives

[knplabs/gaufrette

PHP library that provides a filesystem abstraction layer

2.5k39.8M123](/packages/knplabs-gaufrette)[google/cloud-storage

Cloud Storage Client for PHP

34390.8M125](/packages/google-cloud-storage)[illuminate/filesystem

The Illuminate Filesystem package.

15261.6M2.6k](/packages/illuminate-filesystem)[superbalist/flysystem-google-storage

Flysystem adapter for Google Cloud Storage

26320.6M30](/packages/superbalist-flysystem-google-storage)[creocoder/yii2-flysystem

The flysystem extension for the Yii framework

2931.7M62](/packages/creocoder-yii2-flysystem)[flowjs/flow-php-server

PHP library for handling chunk uploads. Works with flow.js html5 file uploads.

2451.6M15](/packages/flowjs-flow-php-server)

PHPackages © 2026

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