コード例 #1
0
 /**
  * Creates a new Imagen model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Imagen();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
コード例 #2
0
 /**
  * Creates a new Carpeta model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Carpeta();
     $imagen = new Imagen();
     $imagen->load(Yii::$app->request->post());
     if ($model->load(Yii::$app->request->post())) {
         $model->save();
         $imagen->imagen = UploadedFile::getInstance($imagen, 'imagen');
         $imagen->dir = 'imagenes/' . $model->nombre . $imagen->imagen->baseName . '.' . $imagen->imagen->extension;
         $model->link("idPerfil", Yii::$app->user->identity->idPerfil);
         $imagen->save();
         $imagen->link('idCarpeta', $model);
         $imagen->imagen->saveAs($imagen->dir);
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model, 'imagen' => $imagen]);
     }
 }