to add an image in a database and display the same

hi guys, i know this is a known issue but i cannot resolve it,

my table structure is

create table tbl_pic(id integer primary key, name text, password text, imgdata longblob);

My error is:

CException

Property "Pic." is not defined.

public function __set($name,$value)

139 {

140 if($this->setAttribute($name,$value)===false)

141 {

142 if(isset($this->getMetaData()->relations[$name]))

143 $this->_related[$name]=$value;

144 else

145 parent::__set($name,$value);

146 }

147 }

148

i hav attached the necessary files. Anyone pls save time to correct my issue. thanks in advance…

Hi

May be table prefix problem.

tbl_pic than also it consider Pic.

can you try with table name only " pic "

Thanks

thanks for your reply… but still i am getting the same error…

CException

Property "pic1." is not defined.

After changing as you said , i got the above error…

thanks I have solved the prob…

[ code ]

public function actionCreate()


{


	$model=new Images;





	// Uncomment the following line if AJAX validation is needed


	// $this->performAjaxValidation($model);





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


	{


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


		


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


		$myfile=CUploadedFile::getInstance($model,'image_name');


        if (is_object($myfile) && get_class($myfile)==='CUploadedFile') {


        	$model->image_name=$myfile->name;


		}





		if($model->save()) {


			//$model->imagenurl->saveAs('../images/'.$model->idProducto.'_'. $model->imagenurl);


        


			if (is_object($myfile))


	        	$myfile->saveAs(dirname(__FILE__).'/../../images/'.$model->image_name);


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


		}


	}





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


		'model'=>$model,


	));


}

[ /code ]

That above one is workinf…

Please, use [ code ][ /code ] tags when posting a code (<> button).

sure I will … after this

If you have time, then edit your posts with “Edit” button under them :)

Hi i am Pandi This code which path(.php) to use

public function actionCreate()

{

$model=new Images;

// Uncomment the following line if AJAX validation is needed

// $this->performAjaxValidation($model);

if(isset($_POST[‘Images’]))

{

$model->attributes=$_POST[‘Images’];

//$model->image_name = CUploadedFile::getInstance($model,‘image_name’);

$myfile=CUploadedFile::getInstance($model,‘image_name’);

if (is_object($myfile) && get_class($myfile)===‘CUploadedFile’) {

$model->image_name=$myfile->name;

}

if($model->save()) {

//$model->imagenurl->saveAs(’../images/’.$model->idProducto.’_’. $model->imagenurl);

if (is_object($myfile))

$myfile->saveAs(dirname(FILE).’/../../images/’.$model->image_name);

$this->redirect(array(‘view’,‘id’=>$model->image_id));

}

}

$this->render(‘create’,array(

‘model’=>$model,

));

}