To use UploadBehavior, insert the following code to your ActiveRecord class:
php
use mongosoft\file\UploadBehavior;
function behaviors()
{
return [
[
'class' => UploadBehavior::className(),
'attribute' => 'file',
'scenarios' => ['insert', 'update'],
'path' => '@webroot/upload/{id}',
'url' => '@web/upload/{id}',
],
];
}