/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { $model = $this->loadModel($id); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Page'])) { $model->attributes = $_POST['Page']; $model->uid = Yii::app()->user->getId(); $uploadedImage = CUploadedFile::getInstance($model, 'image'); //echo'<pre>';print_r($uploadedImage);echo'</pre>'; if (isset($uploadedImage)) { $ephoto = str_replace(' ', '-', "{$uploadedImage->name}"); $ephoto = 'page_pic_' . $ephoto; $uploadedImage->saveAs(Yii::app()->basepath . '/../images/page/' . $ephoto); $image = Yii::app()->image->load(Yii::app()->basepath . '/../images/page/' . $ephoto); $image->resize(400, 0); $image->save(Yii::app()->basepath . '/../images/page/400/' . $ephoto); $croped_articl = Page::cropImage(Yii::app()->basepath . '/../images/page/400/' . $ephoto); $model->image = $ephoto; } if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('update', array('model' => $model)); }