PHPackages                             tigrov/yii2-upload-behavior - 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. tigrov/yii2-upload-behavior

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

tigrov/yii2-upload-behavior
===========================

File upload behavior for Yii2 ActiveRecord models

1.1.0(6y ago)02MITPHP

Since Jul 31Pushed 6y ago1 watchersCompare

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

READMEChangelogDependencies (1)Versions (3)Used By (0)

yii2-upload-behavior
====================

[](#yii2-upload-behavior)

File upload behavior for Yii2 ActiveRecord models.

[![Latest Stable Version](https://camo.githubusercontent.com/717ad8d13f70187e2c6192a883487df6b0514e17df561090319ad4abbf183f99/68747470733a2f2f706f7365722e707567782e6f72672f546967726f762f796969322d75706c6f61642d6265686176696f722f762f737461626c65)](https://packagist.org/packages/Tigrov/yii2-upload-behavior)

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

[](#installation)

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

Either run

```
php composer.phar require --prefer-dist tigrov/yii2-upload-behavior

```

or add

```
"tigrov/yii2-upload-behavior": "~1.0"

```

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

Usage
-----

[](#usage)

Once the extension is installed, add the behavior to ActiveRecord model as follow:

Create a model with a file attribute

```
class Model extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public function behaviors()
    {
        return [
            'upload' => [
                 'class' => '\tigrov\uploadBehavior\UploadBehavior',
                 'path' => '@runtime/upload',
                 'attributes' => ['file'],
            ],
        ];
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['file'], 'file', 'skipOnEmpty' => false],
        ];
    }
}
```

Create an action in a controller

```
class FormController extends \yii\web\Controller
{
    public function actionUpload()
    {
        $model = new Model();
        if ($model->load(\Yii::$app->request->post()) && $model->save()) {
            \Yii::$app->getSession()->setFlash('success', 'Model is saved.');
            return $this->refresh();
        }

        return $this->render('form', [
            'model' => $model,
        ]);
    }
}
```

Create a form with the file attribute

```

```

After submitting the file it will be saved to specified `path`.

License
-------

[](#license)

[MIT](LICENSE)

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity2

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity60

Established project with proven stability

 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

Every ~5 days

Total

2

Last Release

2472d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/77d285672dec831b7ce5746ab8bb1dd20fffe81fb9d11c232534686706de9697?d=identicon)[Tigros](/maintainers/Tigros)

---

Top Contributors

[![Tigrov](https://avatars.githubusercontent.com/u/8563175?v=4)](https://github.com/Tigrov "Tigrov (5 commits)")

---

Tags

fileuploadyii2extensionBehavior

### Embed Badge

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

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

###  Alternatives

[mohorev/yii2-upload-behavior

Upload behavior for Yii 2

128265.5k9](/packages/mohorev-yii2-upload-behavior)[nemmo/yii2-attachments

Extension for file uploading and attaching to the models

6616.6k5](/packages/nemmo-yii2-attachments)[liyunfang/yii2-upload-behavior

Upload behavior for Yii 2

161.7k](/packages/liyunfang-yii2-upload-behavior)[sjaakp/yii2-illustrated-behavior

ActiveRecord Behavior with associated Widget for Yii2.

423.1k](/packages/sjaakp-yii2-illustrated-behavior)

PHPackages © 2026

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