How Add Thumbnalis

[b]

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[/b]

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,

));

}

[b]

model[/b]

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:

refer here http://www.yiiframework.com/wiki/2/how-to-upload-a-file-using-a-model

klo dari ane, rekomendasi pake ini gan

Extension Image

untuk buat thumbnailnya,




$image = new Image('images/article/' . [filenamenya]);

$image->resize(350, 350, Image::AUTO)->quality(75);

$image->save('images/350x350-' . [filenamenya]);