First declare an attribute to store the file name in the model class (either a form model or an active record model).
Also declare a file validation rule for this attribute to ensure a file is uploaded with specific extension name.
Validators extending from CValidator all have a property named message. You can set this property in the corresponding validation rule to customize the error message. For example, the following validation rule uses an error message that is different from the default one: