Пример #1
0
 /**
  * Creates a new Description model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Description();
     $tag = new Tag();
     if ($model->load(Yii::$app->request->post())) {
         // Upload photo
         $imgName = $model->header;
         if ($model->file = UploadedFile::getInstance($model, 'file')) {
             $model->file->saveAs("uploads/" . $imgName . "." . $model->file->extension);
             $model->photo = "uploads/" . $imgName . "." . $model->file->extension;
         }
         $model->date = date('d-m-Y H:i:s');
         $model->save();
         return $this->redirect(['read', 'id' => $model->desid]);
     } else {
         return $this->render('create', ['model' => $model, 'tag' => $tag]);
     }
 }