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

Jump to content

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

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

#1 User is offline   rajkumar000000 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 88
  • Joined: 18-September 12

Posted 18 October 2012 - 11:49 PM

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..

Attached File(s)


0

#2 User is offline   kiran sharma 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 492
  • Joined: 21-May 11
  • Location:India

Posted 19 October 2012 - 03:06 AM

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); 


Thanks,
Kiran Sharma.
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