如何使用 yii 调整上传图片的大小?
if(isset($_POST['ArsipSurat']))
{
$rnd = rand(0,9999);
$model->attributes=$_POST['ArsipSurat'];
$uploadedFile=CUploadedFile::getInstance($model,'image');
$fileName = "{$rnd}-{$uploadedFile}"; // random number + file name
$model->image = $fileName;
if(isset($uploadedFile)){
$model->save();
//$this->redirect(array('view','id'=>$model->no_surat));
$uploadedFile->saveAs(Yii::app()->basePath.'../../images/arsip/'.$fileName);
//$this->redirect(array('admin'));
$this->redirect(array('view','id'=>$model->no_surat));
}
else if(empty($uploadedFile)) // check if uploaded file is set or not
{
$model->save();
$this->redirect(array('view','id'=>$model->no_surat));
}
else{
//$this->render('create',array('model'=>$model));
$this->redirect(array('admin'));
}
}
我有一张 3000x4000 像素的图片,上传图片时直接调整为 768x1024 像素。我正在尝试$model->resize(768, 1024);
但错误behaviors do not have a method or closure named "resize".