2017 © Pedro Peláez
 

yii2-extension yii2-upload-files-behavior

Upload files via Behavior

image

andrewljashenko/yii2-upload-files-behavior

Upload files via Behavior

  • Tuesday, December 22, 2015
  • by aliashenko-corp-web4pro
  • Repository
  • 1 Watchers
  • 0 Stars
  • 15 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Yii2 Upload Files Behavior

Upload files via Behavior, (*1)

Installation

The preferred way to install this extension is through composer., (*2)

Either run, (*3)

php composer.phar require --prefer-dist andrewljashenko/yii2-upload-files-behavior "*"

or add, (*4)

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

to the require section of your composer.json file., (*5)

Usage

Once the extension is installed, simply use it in your code by :, (*6)

[
    '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, (*7)

<?php $form = ActiveForm::begin(['options' => ['enctype'=>'multipart/form-data']]); ?>
    <?= $form->field($model, 'images[]')->fileInput(['multiple' => true]) ?>
    <?= $form->field($model, 'file')->fileInput() ?>
<?php ActiveForm::end(); ?>

The Versions

22/12 2015

dev-master

9999999-dev

Upload files via Behavior

  Sources   Download

GPL-2.0

The Requires

 

by Andrei Liashenko

upload files image crop multiple images uploadfiles