[Solved] Blank Page At Certain Controller

Hi, it’s me again :)

This is my situation:

  • I have 2 controller, TabelAlumniController and DataPersonController

  • I have 1 model which accessed by two controller above

  • At localhost, everything going well, no problem at all

  • At hosting, views of TabelAlumniController going well but views of DataPersonController = Blank Page

I don’t know where is the problem.

Thank you.

This is my DataPersonController:


<?php

	class DataPersonController extends Controller

	{	

		public $layout='/layouts/column2';

		

		public function filters()

		{

			return array(

				'accessControl', // perform access control for CRUD operations

				'postOnly + delete', // we only allow deletion via POST request

			);

		}

				

		public function accessRules()

		{

			return array(

				array('allow', // allow authenticated user to perform 'create' and 'update' actions

					'actions'=>array('index', 'update'),

					'expression'=>'Yii::app()->user->allAccess()',

				),				

				

				array('deny',  // deny all users

					'users'=>array('*'),

				),				

			);

		}

		

		public function actionIndex()

		{

			$this->render('index');

		}


		

		public function actionUpdate($id)

		{				

			$model=$this->loadModel($id);

			if(isset($_POST['TabelAlumni']))

			{	

				$model->attributes = $_POST['TabelAlumni'];						

				

				$model->tanggal_lahir = $_POST['TabelAlumni']['tanggal_lahir'];

				$file = CUploadedFile::getInstance($model, 'photo');

				

				if(is_object($file) && get_class($file) === 'CUploadedFile')

					$model->photo = $file;

				

				if($model->save())

				{

					//if(!empty($simpanGambar))

					if(is_object($file))

						$model->photo->saveAs(Yii::app()->basePath.'/../images/fotoProfil/'.$model->photo.'');


					Yii::app()->user->setFlash('updateSukses','Data berhasil diperbaharui.');

					$this->redirect(array('index','id'=>$model->id));

				}			

			}	

			$this->render('update');

		}

		

		public function loadModel($id)

		{

			$model=TabelAlumni::model()->findByPk($id);

			if($model===null)

				throw new CHttpException(404,'The requested page does not exist.');

			return $model;

		}

	}



Try to check the log of your web server, i.e error.log for Apache. It should mention something related to the blank page. If you have no access to error.log, try to comment following lines:




if(is_object($file) && get_class($file) === 'CUploadedFile')

    $model->photo = $file;



and add these lines before them:




echo 'Check-01';

exit;



Let’s see whether it still displays the blank page or ‘Check-01’.

Something you can try if you still get the blank page:

First, define public attribute file_diupload at your TabelAlumni model.

Second, modifies your function actionUpdate($id) as follow:




public function actionUpdate($id)

{                               

	$model=$this->loadModel($id);

	if(isset($_POST['TabelAlumni']))

	{       

		$model->attributes = $_POST['TabelAlumni'];

		$model->tanggal_lahir = $_POST['TabelAlumni']['tanggal_lahir'];

		$model->file_diupload = CUploadedFile::getInstance($model, 'photo');

		

		if (!empty($model->file_diupload)) {

			if ($model->save())

			{

				$filename = Yii::app()->basePath.'/../images/fotoProfil/'.$model->file_diupload->name.'.'.

						$model->file_diupload->extensionName;

				$model->file_diupload->saveAs($filename, TRUE);

				Yii::app()->user->setFlash('updateSukses','Data berhasil diperbaharui.');

				$this->redirect(array('index','id'=>$model->id));

			}

		}

		

		$this->render('update');

	}

}



Wow thank you very much for your reply.

Where i must to put the following code??:


if(is_object($file) && get_class($file) === 'CUploadedFile')

    $model->photo = $file;


echo 'Check-01';

exit;

Meanwhile, you can ignore my suggestion with following code:




if(is_object($file) && get_class($file) === 'CUploadedFile')

    $model->photo = $file;


echo 'Check-01';

exit;



I think your problem can be solved by modifying your actionUpdate at your controller and adding public attribute file_diupload at your TabelAlumni model as I mentioned before. It might be caused by the incorrect usage of CUploadedFile::getInstance. Just give a try the modification. If it solves your problem, don’t forget to mention [SOLVED] at this topic. :)

Thank you, thank you very much for your reply.

But i found the problem, my hosting using linux cloud, so name of file/folder/controller case sensitive, that’s why in my localhost (windows) no such problem.