public function actionCreate()
{
$model=new Addwithus;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Addwithus']))
{
$rnd = rand(10,99999); // generate random number between 0-9999
$model->attributes=$_POST['Addwithus'];
$uploadedFile=CUploadedFile::getInstance($model,'pic');
$fileName = "{$rnd}-{$uploadedFile}"; // random number + file name
$model->pic = $fileName;
if($model->save())
$uploadedFile->saveAs(Yii::app()->basePath.'/../images/upload/'.$fileName);
$this->redirect(array('/site/thanks'));
}
$this->render('create',array(
'model'=>$model,
));
}