public function actionUpload() { $model = new BackupUpload(); $form = new CForm('application.models.uploadForm', $model); if ($form->submitted('submit') && $form->validate()) { $form->model->backup = CUploadedFile::getInstance($form->model, 'backup'); $fc = file_get_contents($form->model->backup->tempName); $xml = new SimpleXMLElement($fc, LIBXML_NOCDATA); foreach ($xml->record as $record) { foreach ((array) $record->attributes() as $val) { if (Whitelist::model()->findByAttributes($val) === null) { $tr = new Whitelist(); $tr->attributes = $val; if ($tr->validate()) { $tr->save(); } } } } Yii::app()->user->setFlash('success', 'File Uploaded'); $this->redirect(array('upload')); } $this->render('upload', array('form' => $form)); }