Skip to content

cybercog/yii2-uploadable-file

 
 

Repository files navigation

Yii2 uploadable file

Yii2 extension for upload files

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist maxmirazh33/yii2-uploadable-file "*"

or add

"maxmirazh33/yii2-uploadable-file": "*"

to the require section of your composer.json file.

Usage

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

In your model:

public function behaviors()
    {
        return [
            'uploadFileBehavior' => [
                'class' => \maxmirazh33\file\Behavior::className(),
                'attributes' => [
                    'file' => [
                        'allowEmpty' => true,
                    ],
                    'otherFile',
                ],
            ],
            //other behaviors
        ];
    }

Don't add rules in your model for used attribute. Validator added automatically.

If your need perfectly file input, then in your view file:

echo $form->field($model, 'file')->widget('maxmirazh33\file\Widget');

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published

Languages

  • PHP 100.0%