Hi,
When am uploading an image the data is duplicated in the the db, because of saveAs!
What the mistake ?!
Thanks,
When am uploading an image the data is duplicated in the the db, because of saveAs!
public function actionCreate() { $model=new Article; if(isset($_POST['Article'])) { $model->attributes=$_POST['Article']; $main_image=CUploadedFile::getInstance($model,'main_image'); if(is_object($main_image)){ $MainFileName= uniqid(time(), false); $FileExt = $main_image->getExtensionName(); $model->main_image = $MainFileName.$FileExt; } if($model->save()){ if(is_object($main_image)){ $main_image->saveAs(Yii::app()->basePath.'../../images/'.$MainFileName.".".$FileExt); } $this->redirect(array('view','id'=>$model->id)); } } $this->render('create',array( 'model'=>$model, )); }
What the mistake ?!
Thanks,