if ($model->load(Yii::$app->request->post())){
$image = UploadedFile::getInstance($model, 'image_file');
$fileext=time();
$image->saveAs('uploads/' . $fileext.$image->baseName . '.' . $image->extension);
$model->image_file = $fileext.$image->baseName.'.'.$image->extension;
$model->save();
return $this->redirect(['view', 'id' => $model->id]);
}
else{
return $this->render('create', [
'model' => $model,
]);
}
No comments:
Post a Comment