maxmirazh33/yii2-uploadable-file
最新稳定版本:v2.2.2
Composer 安装命令:
composer require maxmirazh33/yii2-uploadable-file
包简介
Yii2 extension for upload files
README 文档
README
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 [ [ '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.
统计信息
- 总下载量: 499
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-02-06