This extension extends CFileValidator, so it has its basic functionality plus we can validate photo's mime type, min height, min width, max height and max width.
Resources ¶
Documentation ¶
Requirements ¶
- Yii 1.0 or above
Installation ¶
- Extract the release file under
protected/components
Usage ¶
See the following code example:
public function rules()
{
return array(
'photo', 'EPhotoValidator', 'maxWidth'=>800, 'maxHeight'=>600, 'minWidth'=>100, 'minHeight'=>100
);
}
Settings ¶
Another setting not shown above is mimeType which can be plain string with ie: image/jpeg or array of mime types:
public function rules()
{
return array(
'photo','EPhotoValidator','mimeType'=>array(
'image/jpeg','image/gif','image/png'
));
}
Error Messages ¶
For every setting there can be set an error message accessed by field settingError, like: minWidthError, mimeTypeError, maxHeightError etc:
return array(
'photo','EPhotoValidator','mimeType'=>array(
'image/jpeg','image/gif','image/png'
), 'mimeTypeError'=>'Only common types allowed');
Change Log ¶
May 3, 2009 ¶
- Initial release.
Hint
replace line 96 of the validator to
$info=getimagesize($_FILES[get_class($object)]['tmp_name'][$attribute]);
to let it run on newer PHP Versions.
Extension update?
Yii ppl, would you please update http://www.yiiframework.com/extension/ephotovalidator/ with the vladm version?
New release
See forum to get new extension version
multiple uploaded files
I have download the phiras's version and found that it would not work with multiple uploaded files. CUploadedFile, that was extended by this one, uses validateFile method to validate the one uploaded file, and validateAttribute to validate entire attribute, thus to fix this problem you should move additional validation from validateAttribute method to validateFile.
Updated version
Thanks for the good work, actually I did update the validator to cover all the bugs found by waylex, and I added some new things.
please have a look
here.
Greetings,
Firas
A good code base but still needs fixing.
very very nice
so simple...
Multiple Uploads
Can this ext handle multiple uploads? Is there documentation on how to do this? Thanks!
try here
here you can find some updated versions
photovalidator
thanks its work great.
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.