public function run() { /** @var Model | FileSaveBehavior $model */ $model = new $this->model_class(); $model->attachBehavior('file-save', ['class' => FileSaveBehavior::className()]); $model->addFileAttribute('picture', '@beacon_save_dir', '@beacon_view_dir', '@backend_beacon_view_dir', '@frontend_beacon_view_dir', '@beacon_view_url', function ($attribute, $file_path) { HelperImage::resizeByBound($file_path, $file_path, 400); }); $model->saveFiles(); echo json_encode(['filelink' => $model->getFile('picture')]); }
public function behaviors() { return [FileSaveBehavior::className()]; }