if ($model->load(Yii::$app->request->post()) && $model->validate()) {
$value = UploadedFile::getInstance($model, 'logo');
if ($value) {
$name = Yii::$app->security->generateRandomString() . ".{$value->extension}";
$model->logo = $name;
if ($model->save()) {
$value->saveAs(Yii::getAlias('@webroot') . '/uploads/' . $name);
return $this->redirect('/admin/');
}
}
}