Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function actionCreate()
- {
- $model=new File;
- if(isset($_POST['File']))
- {
- $simpan=$model->nama_file=CUploadedFile::getInstance($model,'nama_file');
- if(empty($simpan)){
- $model->attributes=$_POST['File'];
- $model->save();
- }
- else{
- $model->attributes=$_POST['File'];
- $model->pengunggah=Yii::app()->user->id;
- $model->nama_file = CUploadedFile::getInstance($model, 'nama_file');
- if($model->save()){
- $simpan->saveAs(Yii::app()->basePath .
- '/../files/' . $model->nama_file.'');
- //Yii::app()->user->setFlash('success', "Data berhasil disimpan!");
- $this->redirect(array('view','id'=>$model->id_file));
- }
- }
- }
- $this->render('create',array(
- 'model'=>$model,
- ));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement