I have followed this link : http://www.yiiframework.com/wiki/2/how-to-upload-a-file-using-a-model/
Browse option is coming and it is taking image from the drives but after submitting it is displaying an error message : "Image cannot Be Blank"
Following is the ActionCreate() in Controller :
public function actionCreate()
{
$model=new Item;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Item'])){
//$rnd = rand(0,9999);
$model->attributes=$_POST['Item'];
// $uploadedFile=CUploadedFile::getInstance($model,'image');
//$fileName = "{$rnd}-{$uploadedFile}"; // random number + file name
//$model->image = $fileName;
$model->image=CUploadedFile::getInstance($model,'image');
//$valid=$model->validate() ;
//if($valid)
//{
if($model->save()){
// $uploadedFile->saveAs(Yii::app()->basePath.'/../banner/'.$fileName); // image will uplode to rootDirectory/banner/
//$this->redirect(array('admin'));
$model->image->saveAs('E:\wamp\www\uptest\images'.$model->image);
}
/*
if($model->save())
$this->redirect(array('view','id'=>$model->id));*/
}
$this->render('create',array(
'model'=>$model,
));
}
Please do reply for the post. It will be a great help for me. Thanks in Advance.
--
You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to php-fig+u...@googlegroups.com.
To post to this group, send email to php...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/2777fb96-fb8c-486e-af10-f6dc19cb82f1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.