maxmirazh33/yii2-uploadable-file Yii2 extension for upload files

extensionfileupload

Yii2 uploadable file

Yii2 extension for upload files

Latest Version Software License Quality Score Total Downloads

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 [
            [
                'class' => \maxmirazh33\file\Behavior::className(),
                'savePathAlias' => '@web/files/',
                'urlPrefix' => '/files/',
                'attributes' => [
                    'image' => [
                        'savePathAlias' => '@web/images/',
                        'urlPrefix' => '/images/',
                    ],
                    'file',
                ],
            ],
        //other behaviors
        ];
    }

Use rules for validate attribute.

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

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

After, in your view:

echo Html::a('myCoolFile', $model->getFileUrl('file'));

If you use Advanced App Template and this behavior attached in backend model, then in frontend model add trait

use \maxmirazh33\file\GetFileUrlTrait

and use getFileUrl() method for frontend model too.

Changelog

Changelog

All Notable changes to yii2-uploadable-file will be documented in this file

2.2.2

  • Use asset-packagist instead of global fxp composer plugin

2.2.1

  • Fixed issue when file maybe empty

2.2.0

  • Changed extension skeleton

2.1.1

  • Improved GetFileUrlTrait

2.1.0

  • Added GetFileUrlTrait

2.0.1

  • Better definition savePathAlias and urlPrefix

2.0.0

  • Deleted validator adding in behavior

1.0.0

  • Initial release

Statistics

Downloads
GitHub Stars
GitHub Forks

Releases

Comments



v2.2.2 is the latest of 8 releases



MIT license
Stats
2 github stars & 1 github forks
0 downloads in the last day
3 downloads in the last 30 days
477 total downloads