ExcludeMimeType validator checks the MIME
type of transferred files. It supports the following options:
*: Sets any key individually or use a numeric array. Sets the MIME type to validate against.
With this option you can define the MIME type of files that are not to be accepted.
headerCheck: If set to
TRUEthis option will check the HTTP Information for the file type when the fileInfo or mimeMagic extensions can not be found. The default value for this option is
This validator accepts multiple MIME types, either as a
comma-delimited string, or as an array. You may also use the methods
getMimeType() to set and retrieve the MIME
Example 414. Using the ExcludeMimeType Validator
$upload = new Zend_File_Transfer();
// Does not allow MIME type of gif images for all files
$upload->addValidator('ExcludeMimeType', false, 'image/gif');
// Does not allow MIME type of gif and jpg images for all given files
$upload->addValidator('ExcludeMimeType', false, array('image/gif',
// Does not allow MIME type of the group images for all given files
$upload->addValidator('ExcludeMimeType', false, 'image');
The above example shows that it is also possible to disallow groups of MIME types. For example, to disallow all images, just use 'image' as the MIME type. This can be used for all groups of MIME types like 'image', 'audio', 'video', 'text', etc.
Note that disallowing groups of MIME types will disallow all members of this group even if this is not intentional. When you disallow 'image' you will disallow all types of images like 'image/jpeg' or 'image/vasa'. When you are not sure if you want to disallow all types, you should disallow only specific MIME types instead of complete groups.