Created
February 21, 2015 03:04
-
-
Save mdmunir/119a55bdbe329c600f1c to your computer and use it in GitHub Desktop.
Penggunaan yii2-upload-file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// class User | |
class User extends ActiveRecord | |
{ | |
... | |
public function behaviors() | |
{ | |
return [ | |
[ | |
'class' => 'mdm\upload\UploadBehavior', | |
'savedAttribute' => 'avatar_id', // <- untuk nyimpan id file | |
], | |
]; | |
} | |
} | |
?> | |
// Cara mengakses avatar | |
<?= Yii::$app->user->identity->username ?> | |
<?= Html::img(['/file', 'id' => $model->Yii::$app->user->identity->avatar_id]) ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment