Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

How Add Thumbnalis

$
0
0

hey i need add thumbnalis for this code this is image upload as URL i try add thumbnail for this but it not work properly


public function actionCreate()
{
$model=new Cities;

// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);

if(isset($_POST['Cities']))
{
$model->attributes=$_POST['Cities'];
//image upload
$myfile=CUploadedFile::getInstance($model,'image');
if (is_object($myfile) && get_class($myfile)==='CUploadedFile') {
// gimage upload path edite with your path
$model->image="http://10.0.2.2/sitename/images/cities/{$myfile->name}";
}
if($model->save())

$myfile->saveAs(Yii::app()->basePath.'/../images/'.$myfile->name);//save image
$this->redirect(array('view','id'=>$model->city_id));
}

$this->render('create',array(
'model'=>$model,
));
}

model


public function rules()

array('image', 'file','types'=>'jpg, gif, png', 'allowEmpty'=>true, 'on'=>'update'),
array(' image', 'length', 'max'=>255, 'on'=>'insert,update'),


i newer on YII wall please help thank you


;D :blink: :blink:

Viewing all articles
Browse latest Browse all 18717

Trending Articles