但我的问题是,当我尝试上传图片时,它会一直这样说:致命错误:在非对象上调用成员函数saveAs()
*/
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,
));
}
粗体是产生如此多问题的代码片段,我在互联网上搜索但所提供的所有解决方案都没有解决任何问题。