andrewljashenko / yii2-upload-files-behavior
Upload files via Behavior
Package info
github.com/aliashenko-corp-web4pro/yii2uploadbehavior
Type:yii2-extension
pkg:composer/andrewljashenko/yii2-upload-files-behavior
dev-master
2015-12-22 12:44 UTC
Requires
- gregwar/image: 2.*
- yiisoft/yii2: *
This package is not auto-updated.
Last update: 2026-03-05 01:52:00 UTC
README
Upload files via Behavior
Installation
The preferred way to install this extension is through composer.
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
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
<?php $form = ActiveForm::begin(['options' => ['enctype'=>'multipart/form-data']]); ?> <?= $form->field($model, 'images[]')->fileInput(['multiple' => true]) ?> <?= $form->field($model, 'file')->fileInput() ?> <?php ActiveForm::end(); ?>