Yii 1.1: ephotovalidator

Uploaded photo validator

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.




  • Yii 1.0 or above


  • Extract the release file under protected/components


See the following code example:

public function rules()
    return array(
        'photo', 'EPhotoValidator', 'maxWidth'=>800, 'maxHeight'=>600, 'minWidth'=>100, 'minHeight'=>100


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(

Error Messages

For every setting there can be set an error message accessed by field settingError, like: minWidthError, mimeTypeError, maxHeightError etc:

return array(
        ), 'mimeTypeError'=>'Only common types allowed');

Change Log

May 3, 2009

  • Initial release.

Total 10 comments

#11761 report it
rajesh chaurasia at 2013/02/01 11:34pm

thanks its work great.

#3719 report it
Gustavo at 2011/05/01 10:51pm
try here

here you can find some updated versions

#3056 report it
waterloomatt at 2011/03/10 09:51pm
Multiple Uploads

Can this ext handle multiple uploads? Is there documentation on how to do this? Thanks!

#101 report it
thyseus at 2010/09/16 03:10am

replace line 96 of the validator to


to let it run on newer PHP Versions.

#875 report it
phiras at 2010/02/14 06:27am
Extension update?

Yii ppl, would you please update http://www.yiiframework.com/extension/ephotovalidator/ with the vladm version?

#985 report it
vladm at 2010/01/14 11:41pm
New release

See forum to get new extension version

#987 report it
vladm at 2010/01/14 06:57pm
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.

#1263 report it
phiras at 2009/10/09 01:38pm
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.



#1376 report it
sergeymorkovkin at 2009/08/19 07:37am
A good code base but still needs fixing.
  1. Incorrectly validates min/max image height.
  2. Validates on a non-uploaded file and causes an error when allowEmpty is set true.
  3. Add colons after embedded error messages.
  4. Remove repeated getimagesize call when mimeType is being validated.
  5. Need to handle a situation when uploaded file has correct extension but isn't image, getimagesize will return false.
#1535 report it
mb at 2009/07/01 11:23am
very very nice

so simple...

Leave a comment

Please to leave your comment.

Create extension
  • Yii Version: 1.1
  • License: Other Open Source License
  • Developed by: emix
  • Category: Validation
  • Votes: +11 / -1
  • Downloaded: 1,428 times
  • Created on: May 3, 2009
  • Last updated: May 4, 2009