How to validate an image in Yii framework so that the user should upload image of certain resolution or below? ex: resolution below 600x500 not bigger than that??
Please help! Thanks!
How to validate an image in Yii framework so that the user should upload image of certain resolution or below? ex: resolution below 600x500 not bigger than that??
Please help! Thanks!
Hi
you should make your own validator
public function imageSize($attribute,$params)
{
//...$uplodedImageUrl is the path of uploaded file
$info = getimagesize($uplodedImageUrl);
$imagewidth = $info[0];
$imageheight = $info[1];
if ($imagewidth>600 || $imageheight>500)
$this->addError('image','The image should be maximum 600x500');
}
add in rules method
...
array('image','imageSize')
...