665. Class

665.1. Zend\Validator\File\MimeType

Validator for the mime type of a file

665.1.1. Methods

665.1.1.1. __construct

__construct()

Sets validator options

Mimetype to accept - NULL means default PHP usage by using the environment variable ‘magic’ - FALSE means disabling searching for mimetype, should be used for PHP 5.3 - A string is the mimetype file to use

Parameters:string|array|Traversable

665.1.1.2. getMagicFile

getMagicFile()

Returns the actual set magicfile

Return type:string

665.1.1.3. setMagicFile

setMagicFile()

Sets the magicfile to use if null, the MAGIC constant from php is used if the MAGIC file is erroneous, no file will be set if false, the default MAGIC file from PHP will be used

Parameters:string
Return type:MimeType Provides fluid interface
Throws :ExceptionRuntimeException When finfo can not read the magicfile
Throws :ExceptionInvalidArgumentException
Throws :ExceptionInvalidMagicMimeFileException

665.1.1.4. disableMagicFile

disableMagicFile()

Disables usage of MagicFile

Parameters:$disable – False disables usage of magic file
Return type:MimeType Provides fluid interface

665.1.1.5. isMagicFileDisabled

isMagicFileDisabled()

Is usage of MagicFile disabled?

Return type:bool

665.1.1.6. getHeaderCheck

getHeaderCheck()

Returns the Header Check option

Return type:bool

665.1.1.7. enableHeaderCheck

enableHeaderCheck()

Defines if the http header should be used Note that this is unsafe and therefor the default value is false

Parameters:bool
Return type:MimeType Provides fluid interface

665.1.1.8. getMimeType

getMimeType()

Returns the set mimetypes

Parameters:bool – Returns the values as array, when false a concatenated string is returned
Return type:string|array

665.1.1.9. setMimeType

setMimeType()

Sets the mimetypes

Parameters:string|array – The mimetypes to validate
Return type:MimeType Provides a fluent interface

665.1.1.10. addMimeType

addMimeType()

Adds the mimetypes

Parameters:string|array – The mimetypes to add for validation
Return type:MimeType Provides a fluent interface
Throws :ExceptionInvalidArgumentException

665.1.1.11. isValid

isValid()

Defined by ZendValidatorValidatorInterface

Returns true if the mimetype of the file matches the given ones. Also parts of mimetypes can be checked. If you give for example “image” all image mime types will be accepted like “image/gif”, “image/jpeg” and so on.

Parameters:string|array – Real file to check for mimetype
Return type:bool

665.1.2. Constants

665.1.2.1. FALSE_TYPE

665.1.2.2. NOT_DETECTED

665.1.2.3. NOT_READABLE