Fatal error: Call to a member function saveAs() on a non-object
I am following this tutorial:
http://www.yiiframework.com/wiki/349/how-to-upload-image-photo-and-path-entry-in-database-with-update-functionality/#hh0
but my problem is when i try to upload the image it gets all the time
saying this: Fatal error: Call to a member function saveAs() on a
non-object
*/
public function actionCreate()
{
$model=new Imagem;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Imagem']))
{
$rnd = rand(0,9999);
$model->attributes=$_POST['Imagem'];
$uploadedFile=CUploadedFile::getInstance($model,'image');
$fileName = "{$rnd}-{$uploadedFile}";
if($model->save()){
**$uploadedFile->saveAs(Yii::app()->basePath.'/../imagem/'.$fileName);**
$this->redirect(array('admin'));
}
}
$this->render('create',array(
'model'=>$model,
));
}
On bold is the piece of the code that is generating so much problems, i
searched in the internet but all the solutions provided don't solve
anything.
No comments:
Post a Comment