i want to resize image before upload to database. 100x100 size.
i store the image to table files.
CREATE TABLE files (
id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(60) NOT NULL,
file BLOB NOT NULL,
file_type VARCHAR(60) NOT NULL,
file_size INT UNSIGNED NOT NULL
)
public function actionCreate()
{
$model=new CalonPengajar;
$file_model = new Files;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['CalonPengajar']))
{
$model->attributes=$_POST['CalonPengajar'];
$file=CUploadedFile::getInstance($model,'image');
if($model->save()){
$file_model->name = $file->name;
$file_model->id_calon_pengajar = $model->id;
$file_model->file_type=$file->type;
$file_model->file_size=$file->size;
$file_model->file=file_get_contents($file->tempName);
<<<< I WANT RESIZE IMAGE BEFORE SAVE TO 100X100>>>
$file_model->save(); // DONE
$this->redirect(array('view','id'=>$model->id));
}
}
$this->render('create',array(
'model'=>$model,
));
}