Advertisement
joris

Contoh Upload File

Feb 28th, 2014
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.65 KB | None | 0 0
  1. public function actionCreate()
  2.     {  
  3.         $model=new Registration;
  4.  
  5.         if(isset($_POST['Registration']))
  6.         {
  7.             $rnd = rand(0,9999999999);
  8.             $model->attributes=$_POST['Registration'];
  9.            
  10.             $uploadedFile = CUploadedFile::getInstance($model,'scan_ktp');
  11.             $fileName = $rnd.".".$uploadedFile->getExtensionName();
  12.            
  13.             $model->scan_ktp = $fileName;
  14.            
  15.             if($model->save()){
  16.                
  17.                 $uploadedFile->saveAs(Yii::app()->basePath.'/../scan/'.$fileName);
  18.                 Yii::app()->user->setFlash('success', 'Data anda telah tersimpan pada database aplikasi.');
  19.                 $this->refresh();
  20.             }
  21.                
  22.         }
  23.  
  24.         $this->render('create',array(
  25.             'model'=>$model,
  26.         ));
  27.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement