Usage at [[\yii\base\Model::behaviors()]] add the following code ~~~ return [ ... [ 'class' => 'mdm\upload\UploadBehavior', 'uploadPath' => '@common/upload', // default to '@runtime/upload' 'attribute' => 'file', // attribute use to receive from FileField 'savedAttribute' => 'file_id', // attribute use to receive id of file ], ]; ~~~
Since: 1.0
Author: Misbahul D Munir (misbahuldmunir@gmail.com)
Inheritance: extends yii\base\Behavior
示例#1
0
文件: Order.php 项目: kvaxminsk/evo8
 public function behaviors()
 {
     return [['class' => TimestampBehavior::className(), 'value' => new \yii\db\Expression('NOW()')], ['class' => UploadBehavior::className(), 'attribute' => 'file', 'savedAttribute' => 'files', 'uploadPath' => '@webroot/uploads/files']];
 }
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     $this->uploadPath = Yii::getAlias($this->uploadPath);
 }
示例#3
0
 public function behaviors()
 {
     return [['class' => UploadBehavior::className(), 'attribute' => 'file', 'savedAttribute' => 'avatar', 'uploadPath' => '@webroot/uploads']];
 }