Esempio n. 1
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionAjaxAdd($id)
 {
     $albumPhoto = CUploadedFile::getInstanceByName('namaFile');
     $album_path = "public/album/" . $id;
     $fileName = time() . '_' . $id . '_' . Utility::getUrlTitle(Albums::getInfo($id, 'title')) . '.' . strtolower($albumPhoto->extensionName);
     if ($albumPhoto->saveAs($album_path . '/' . $fileName)) {
         $model = new AlbumPhoto();
         $model->album_id = $id;
         $model->media = $fileName;
         if ($model->save()) {
             $url = Yii::app()->controller->createUrl('ajaxmanage', array('id' => $model->album_id));
             echo CJSON::encode(array('id' => 'media-render', 'get' => $url));
         }
     }
 }