Zend Framework
LICENSE
This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to license@zend.com so we can send you a copy immediately.
Validator for the mime type of a file

array
$_magicFiles= 'array(
'/usr/share/misc/magic''
If no $_ENV['MAGIC'] is set, try and autodiscover it based on common locations
array(
'/usr/share/misc/magic'
Details
array
$_messageTemplates= 'array(
self::FALSE_TYPE => "File '%value%' has a false mimetype of '%type%'"'
array(
self::FALSE_TYPE => "File '%value%' has a false mimetype of '%type%'"
Details
array
$_messageVariables= 'array(
'type' => '_type'
)'
array(
'type' => '_type'
)
Details
__construct(
string|array $mimetype
)
:
void
Sets validator options
Mimetype to accept
Name | Type | Description |
---|---|---|
$mimetype | string|array | MimeType |

_throw(
string $file, string $errorType
)
:
false
Throws an error of the given type
Name | Type | Description |
---|---|---|
$file | string | |
$errorType | string |
Type | Description |
---|---|
false |

addMimeType(
string|array $mimetype
)
:
\Zend_Validate_File_Extension
Adds the mimetypes
Name | Type | Description |
---|---|---|
$mimetype | string|array | The mimetypes to add for validation |
Type | Description |
---|---|
\Zend_Validate_File_Extension | Provides a fluent interface |

enableHeaderCheck(
$headerCheck
=
true
)
:
\Zend_Validate_File_MimeType
Defines if the http header should be used Note that this is unsave and therefor the default value is false
Name | Type | Description |
---|---|---|
$headerCheck |
Type | Description |
---|---|
\Zend_Validate_File_MimeType | Provides fluid interface |

getMimeType(
boolean $asArray
=
false
)
:
string|array
Returns the set mimetypes
Name | Type | Description |
---|---|---|
$asArray | boolean | Returns the values as array, when false an concated string is returned |
Type | Description |
---|---|
string|array |

isValid(
string $value, array $file
=
null
)
:
boolean
Defined by Zend_Validate_Interface
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.
Name | Type | Description |
---|---|---|
$value | string | Real file to check for mimetype |
$file | array | File data from Zend_File_Transfer |
Type | Description |
---|---|
boolean |

setMagicFile(
string $file
)
:
\Zend_Validate_File_MimeType
Sets the magicfile to use if null, the MAGIC constant from php is used if the MAGIC file is errorous, no file will be set
Name | Type | Description |
---|---|---|
$file | string |
Type | Description |
---|---|
\Zend_Validate_File_MimeType | Provides fluid interface |
Exception | Description |
---|---|
\Zend_Validate_Exception | When finfo can not read the magicfile |

setMimeType(
string|array $mimetype
)
:
\Zend_Validate_File_Extension
Sets the mimetypes
Name | Type | Description |
---|---|---|
$mimetype | string|array | The mimetypes to validate |
Type | Description |
---|---|
\Zend_Validate_File_Extension | Provides a fluent interface |