I have same Problem.....
[u]My view part is[/u] :
<div class="row">
<?php echo $form->labelEx($model,'product_picture'); ?>
<?php echo CHtml::activeFileField($model,'product_picture'); ?>
<?php echo $form->error($model,'product_picture'); ?>
</div>
[u]My Model part is :[/u]
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('product_name, product_category, product_picture, product_buy_rate, product_sale_rate, product_description, product_stock_status, product_avail_stock', 'required'),
array('product_buy_rate, product_sale_rate, product_avail_stock', 'numerical', 'integerOnly'=>true),
array('product_name', 'length', 'max'=>30),
[size="5"][b]array('product_picture', 'file', 'types'=>'jpg, gif, png', 'allowEmpty' => true,),[/b][/size]
array('product_category ','length', 'max'=>100),
array('product_description', 'length', 'max'=>300),
array('product_stock_status', 'length', 'max'=>10),
// The following rule is used by search().
// @todo Please remove those attributes that should not be searched.
array('product_id, product_name, product_category, product_picture, product_buy_rate, product_sale_rate, product_description, product_stock_status, product_avail_stock', 'safe', 'on'=>'search'),
);
}
[u]
My Controller part is :[/u]
public function actionCreate()
{
$model=new Product;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Product']))
{
$model->attributes=$_POST['Product'];
//$rnd = rand(0,9999);
$uploadedFile = CUploadedFile::getInstance($model,'product_picture');
$fileName =date(time()). '-' . $model->product_picture;
$model->product_picture = $fileName;
if($model->save()){
$uploadpath = Yii::app()->theme->basePath.'/adminpanel/Upload/'.$fileName;
$uploadedFile->saveAs($uploadpath);
$this->redirect(array('view','id'=>$model->product_id));
}
}
$this->render('create',array(
'model'=>$model,
));
}
.................
I goe some error :
fatal error call to a member function save as() on a non-object
Plz help