예제 #1
0
 /**
  * Creates a new CuentasIp model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new CuentasIp();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         // Obteniendo el archivo que se subió.
         $model->archivo = UploadedFile::getInstance($model, 'archivo');
         if ($model->archivo && $model->validate()) {
             $nombreImagen = $model->cuenta . '-' . date('Ymd-His');
             // Guardando la direccion en la BD
             $model->docto_propuesta = 'doctos/' . $nombreImagen . '.' . $model->archivo->extension;
             $model->save();
             $model->archivo->saveAs('doctos/' . $nombreImagen . '.' . $model->archivo->extension);
         }
         return $this->redirect(['index', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }