Yii2 Upload File Behavior
The preferred way to install this extension is through composer.
Either run
composer require --prefer-dist yiidoc/yii2-upload-behavior "*"
or add
"yiidoc/yii2-upload-behavior": "*"
to the require section of your composer.json
file.
Once the extension is installed, simply use it in your code by :
public function behaviors()
{
return [
[
'class' => 'yii\behaviors\UploadFileBehavior',
'attribute' => 'picture',
'uploadDir' => '@webroot/uploads/user/pictures'
]
];
}