I have an image upload in the application and expects to check the rule in this order.
Other than image type, show image type error.
Size > 1MB, show size error.
The rule is as follows:
array('ImagePath', 'file','allowEmpty'=>true,'types'=>'jpg, gif, png,jpeg', 'wrongType' => Yii::t('error','Logo file type should be JPG, GIF or PNG'),'maxSize' => 1048576,'tooLarge' => Yii::t('error','Logo file size should be less than 1 MB')),
Now if I upload a 2MB size PDF file, I expect to show error "Logo file type should be JPG, GIF or PNG".But it is throwing
the error for size “'Logo file size should be less than 1 MB”.
How can I handle the rule to give preference to rule in order image type and then image size respectively?