The ExcludeExtension validator checks the file extension of the
specified files. It supports the following options:
*: Sets any key or use a numeric array. The values will be used to check whether the given file does not use this file extension.
case: Sets a boolean indicating whether validation should be case-sensitive. The default is not case sensitive. Note that this key can be applied to for all available extensions.
This validator accepts multiple extensions, either as a comma-delimited string, or as
an array. You may also use the methods setExtension(),
addExtension(), and getExtension()
to set and retrieve extensions.
In some cases it is useful to match in a case-sensitive fashion. So the constructor
allows a second parameter called $case which, if set to
TRUE, validates the extension by comparing it with the specified
values in a case-sensitive fashion.
Example 400. Using the ExcludeExtension Validator
<?php
$upload = new Zend_File_Transfer();
// Do not allow files with extension php or exe
$upload->addValidator('ExcludeExtension', false, 'php,exe');
// Do not allow files with extension php or exe, but use array notation
$upload->addValidator('ExcludeExtension', false, array('php', 'exe'));
// Check in a case-sensitive fashion
$upload->addValidator('ExcludeExtension',
false,
array('php', 'exe', 'case' => true));
$upload->addValidator('ExcludeExtension',
false,
array('php', 'exe', 'case' => true));
Note
Note that this validator only checks the file extension. It does not check the file's MIME type.




