This validator validates the absence of requested file and optionally you can rename the $object->$attribute and save the file using the $object->$attribute.
- Properties :
- string $path the path to look up
- boolean $renameIfExists can be used to rename the $object->$attribute if the file already exists. Defaults to true.
- boolean $allowEmpty can be used to set allow empty file upload. Defaults to true
- string $emptyMessage can be used to display error when file is empty
- string $existMessage can be used to display error when file already exists
Requirements ¶
Yii 1.1
Installation and Usage ¶
Copy this validator to protected/extensions
Inside rules() of your model use like this : array('file','ext.validator.NotExists','path'=>'images/','allowEmpty'=>false,'renameIfExists'=>false,'emptyMessage'=>'{attribute} is empty','existMessage'=>'{value} already exists'),
...you can use the validator like the following...
public function rules()
{
return array(
....
.... array('file','ext.validator.NotExists','path'=>'images/','allowEmpty'=>false,'renameIfExists'=>false,'emptyMessage'=>'{attribute} is empty','existMessage'=>'{value} already exists'),
....
....
);
}
Great !!
Nice one.
How is it?
hi guys does it works as expected?
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.