Fatal Error: Call To A Member Function Saveas() On A Non-Object

i am trying to upload image in my application in which data is go to the database table(tbl_image)and not reach the images in this path "C:/xampp/htdocs/new/images.i think some problem to reach appropriate place using (saveAs()).

i have found error that is:

object(CUploadedFile)[58]

private ‘_name’ => string ‘ajit.jpg’ (length=8)

private ‘_tempName’ => string ‘C:\xampp\tmp\php4896.tmp’ (length=24)

private ‘_type’ => string ‘image/jpeg’ (length=10)

private ‘_size’ => int 11914

private ‘_error’ => int 0

private ‘_e’ (CComponent) => null

private ‘_m’ (CComponent) => null

( ! ) Fatal error: Call to a member function saveAs() on a non-object in C:\xampp\htdocs\notjustprice\protected\controllers\ImageController.php on line 106

Call Stack

Time Memory Function Location

1 0.0041 141168 {main}( ) …\index.php:0

2 0.0809 1101824 CApplication->run( ) …\index.php:13

3 0.0809 1101920 CWebApplication->processRequest( ) …\CApplication.php:162

i tried very much after that i am not able to reach my goal…

Any help is appreciated.

Thanks a lot for the support me…

my models,view,controller files are…

In your code i found you using wiki article written by Me :)

check below code lines,




$uploadedFile=CUploadedFile::getInstance($model,'uploadedFile');   // here uploadedFile must be uploaded file instance


$model->image_index = $fileName; // this will set   image_index  model attribute as file name


// use below code line to upload image

$uploadedFile->saveAs("C:/xampp/htdocs/new/images/".$fileName);