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

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

andrewljashenko/yii2-upload-files-behavior
==========================================

Upload files via Behavior

015PHP

Since Dec 22Pushed 10y ago1 watchersCompare

[ Source](https://github.com/aliashenko-corp-web4pro/yii2uploadbehavior)[ Packagist](https://packagist.org/packages/andrewljashenko/yii2-upload-files-behavior)[ RSS](/packages/andrewljashenko-yii2-upload-files-behavior/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Yii2 Upload Files Behavior
==========================

[](#yii2-upload-files-behavior)

Upload files via 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 andrewljashenko/yii2-upload-files-behavior "*"

```

or add

```
"andrewljashenko/yii2-upload-files-behavior": "*"

```

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

Usage
-----

[](#usage)

Once the extension is installed, simply use it in your code by :

```
[
    'class' => UploadFilesBehavior::className(), //Behavior class
    'attributes' => [
        [
            'attribute' => 'images',
            'uploadPath' => '@common/images',
            'sizes' => [[100, 100], [200, 250]]
        ],
        [
            'attribute' => 'file',
            'uploadPath' => '@common/files',
        ],
    ]
]
```

Don't forget enable enctype into ActiveForm

```
