Download and extract
this file in protected/extensions directory.
In config/main.php file, add the following element to components array
'image'=>array(
'class'=>'application.extensions.image.CImageComponent',
'driver'=>'GD',
)
Now in action, insert the following code and modify paths
$model->Picture = CUploadedFile::getInstance($model,'Picture');
if( is_object($model->Picture) )
{
mkdir(getcwd().'/images/users/'.$model->Id."/");
$name = getcwd().'/images/users/'.$model->Id."/".$model->Picture->getName();
$model->Picture->saveAs($name);
$image = Yii::app()->image->load($name);
$image->resize(50, 50);
$image->save();
}
Source: http://docs.kohanaphp.com/libraries/image
10 Comments
'image'
=>
array
(
2
'class'
=>
'application.extensions.image.CImageComponent'
,
3
'driver'
=>
'GD'
,
4
}
This should be ) at line 4 not } there.
Thanks Jonathan for point this out 🙂
i follow the exam . error “image file not found ”
help me…!
Have you modified the paths given at line # 04 and 05 to suit your application?
upload
Thanks, my questions have been resolved.
Thx, I stressed it for 2 days before i found your little tips
Thanks, It helped me.
Hi,
thanks.. this is excellent work… working for me…
I change size to 150 X 150 .. but it resize the image to 150 X 113.
something I missing… here is code below..
if($thumbimageUploadFile !== null )
{
$thumbimageUploadFile->saveAs(YiiBase::getPathOfAlias(‘webroot’).’/upload/brochure/thumb/’.$model->thumbimage);
$image = Yii::app()->image->load(YiiBase::getPathOfAlias(‘webroot’).’/upload/brochure/thumb/’.$model->thumbimage);
$image->resize(150, 150);//resize the image
$image->save();
}
file that should download it to extract it in {protected/extensions} not found