Buat import data kontak

maaf master saya lagi kebingungan nih ada yang bisa bantu gak cara membuat form import kontak untuk sms gateway…

ini file controller yang sudah di buat,




public function actionImport(){

		$model=new Contact;

		require_once Yii::app()->basePath.'/extensions/upload/excel_reader2.php';

       

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

   {

     $a=$model->validate();

     if ($a) {

       //upload file

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

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

       $file->saveAs(Yii::app()->basePath.'/extensions/upload/import.xls');

                   

       //Read excel to array

       $path=Yii::app()->basepath.'/extensions/upload/import.xls';

       $data = new Spreadsheet_Excel_Reader($path);

       $mem=array();

       $cont=array();

                       

       $berhasil=0;

       $gagal= 0;

       //insert into database

       for ($j=2; $j <= $data->sheets[0]['numRows']; $j++)

          {

             $mem[$j]=$data->sheets[0]['cells'][$j][1];

             $cont[$j]=$data->sheets[0]['cells'][$j][2];

               

             $model= new Contact;

             $model->member=$mem[$j];

             $model->contact=$cont[$j];;

             $model->save();

              

               //hitung record

               if(!$model->save()){

                 $gagal++;

               } else {

                 $berhasil++;

               }  

          }

        Yii::app()->user->setFlash('sukses',$berhasil.' record

        berhasil disimpan dan '.$gagal.' record gagal disimpan..');

        //hapus file excel

        unlink ($path);

        $this->redirect(array('admin'));

       }

    }

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

			'model'=>$model,

		));

}



formnya,




<?php $form=$this->beginWidget('bootstrap.widgets.TbActiveForm', array(

    'id'=>'import-form',

    'enableAjaxValidation'=>false,

    'htmlOptions'=> array('enctype'=>'multipart/form-data'),

)); ?>


	<p class="help-block">Fields with <span class="required">*</span> are required.</p>


        <?php echo $form->labelEx($model,'file_excel'); ?>

        <?php echo $form->Filefield($model,'file_excel'); ?>

        <?php echo $form->error($model,'file_excel'); ?>

		

		<div class="form-actions">

		<?php $this->widget('bootstrap.widgets.TbButton', array(

			'buttonType'=>'submit',

			'type'=>'primary',

			'label'=>$model->isNewRecord ? 'Tambah' : 'Save',

		)); ?>

	</div>


<?php $this->endWidget(); ?>



dan di modelnya,




 

	public function rules()

	{

		// NOTE: you should only define rules for those attributes that

		// will receive user inputs.

		return array(

			array('member, contact', 'required'),

			array('member, contact', 'length', 'max'=>50),

			array('filee','file','types'=>'xls',

           'maxSize'=>5242880,

           'allowEmpty' => true,

           'wrongType'=>'Only csv allowed.',

           'tooLarge'=>'File too large! 5MB is the limit'),

			array('filee','safe','on'=>'excel'),

			// The following rule is used by search().

			// @todo Please remove those attributes that should not be searched.

			array('contact_id, member, contact', 'safe', 'on'=>'search'),

		);

	}




setelah di klik tambah gak terjadi apa-apa gak ada error, tapi datanya gak masuk. terima kasih