Yii Framework Forum: Mohon Bantuanya Gan : Undefined Variable - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Mohon Bantuanya Gan : Undefined Variable Undefined variable: picture_file Rate Topic: -----

#1 User is offline   hypia 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 03-January 14

  Posted 03 January 2014 - 10:53 PM

Mohon bantuanya gan ane kenak eror code controllernya gan....


public function actionCreate()
{
$model=new Propinsi;
if(isset($_POST['Propinsi']))
{
$model->attributes=$_POST['Propinsi'];

$gambar = CUploadedFile::getInstanceByName('logo_prop');

if($gambar){

$nama_gambar = $gambar->name;
$picture_file->SaveAs(Yii::app()->basePath . '/images/foto/' . $nama_gambar);

$model->logo=$nama_gambar;

if($model->save()) {
$this->redirect(array('view','id'=>$model->idpropinsi));
}
}
}


ERORNYA : Undefined variable: picture_file
0

#2 User is offline   Zein Miftah 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 19
  • Joined: 18-March 13

Posted 06 January 2014 - 03:22 AM

Dari code ini

$gambar = CUploadedFile::getInstanceByName('logo_prop');


bagusnya seperti ini gan
$gambar->SaveAs(Yii::app()->basePath . '/images/foto/' . $nama_gambar);

0

#3 User is offline   hidenobu 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 15-January 14

Posted 23 January 2014 - 11:20 PM

gan mau tanya kalo untuk export database ke csv gimana ya
0

#4 User is offline   dst34m 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 70
  • Joined: 07-November 12

Posted 25 January 2014 - 12:55 AM

coding agan yg ini
$picture_file->SaveAs(Yii::app()->basePath . '/images/foto/' . $nama_gambar);


variabel nya harusnya merujuk ke
$gambar = CUploadedFile::getInstanceByName('logo_prop');


jadi
$gambar->SaveAs(Yii::app()->basePath . '/images/foto/' . $nama_gambar)



ini coding create upload gambar ane gan...

public function actionCreate()
	{
		$model=new EMPLOYEE;

		// Uncomment the following line if AJAX validation is needed
		// $this->performAjaxValidation($model);

		if(isset($_POST['EMPLOYEE']))
		{
			$model->attributes=$_POST['EMPLOYEE'];
			
			
			$simpanGambar=CUploadedFile::getInstance($model,'EMP_PHOTO');
			$model->EMP_PHOTO=$model->EMP_ID.'.jpg';
			
			if($model->save())
			{
				if(isset($simpanGambar)){
					$simpanGambar->saveAs(Yii::app()->basePath.'/../photo/'.$model->EMP_PHOTO);
				}
				
				Yii::app()->user->setFlash('success', '<strong>Well done!</strong> Data karyawan baru berhasil disimpan.');
				//$this->redirect(array('view','id'=>$model->EMP_ID));
				$this->redirect(array('create'));
			}
		}

		$this->render('create',array(
			'model'=>$model,
		));
	}


semoga membantu
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users