Upload Excel file

Hi all…

I want to ask about How to upload file on local directory

This is my situation :

  1. I use Win Xp

  2. I have followed

This is My Code in Controller :




public function actionCreate()

	{

		$model=new StudentA;

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

		{

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

                        $model->Excel = $_POST['StudentA']['Excel'];

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

			if($model->save())

                        {

                            $model->Excel->saveAs('.\Temporary');

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

                        }

		}

		$this->render('create',array(

			'model'=>$model,

		));

	}



I still have an error on :

are there any one know about this problem.

Thanks a lot

I guess that you should save like $model->Excel->saveAs(’.\Temporary\uniqueNameForExcelFile.xls’)

Why not to save in a blob? It’s easier and avoid problems of removing old file, write permission and so on.