public function actionCreate() { $model = new Peserta(); if (isset($_POST['Peserta'])) { $model->attributes = $_POST['Peserta']; $model->code_reg = Peserta::randomCode(); $model->FOTO_PESERTA = CUploadedFile::getInstance($model, 'FOTO_PESERTA'); if ($model->save()) { $model->FOTO_PESERTA->saveAs(Yii::app()->basePath . self::URLUPLOAD . $model->FOTO_PESERTA . ''); } $this->redirect(array('view', 'id' => $model->ID_PESERTA)); } $this->render('create', array('model' => $model)); }