dev-master
9999999-devUpload files via Behavior
GPL-2.0
The Requires
by Andrei Liashenko
upload files image crop multiple images uploadfiles
Upload files via Behavior
Upload files via Behavior, (*1)
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)
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(); ?>
Upload files via Behavior
GPL-2.0
upload files image crop multiple images uploadfiles