API Documentation

Zend/Validate/File/MimeType.php

Show: inherited
Table of Contents

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.

Category
Zend  
Copyright
Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Package
Zend_Validate  
Version
$Id: MimeType.php 24594 2012-01-05 21:27:01Z matthew $  

\Zend_Validate_File_MimeType

Package: Zend\Validate

Validator for the mime type of a file

Parent(s)
\Zend_Validate_Abstract
Children
\Zend_Validate_File_ExcludeMimeType
\Zend_Validate_File_IsImage
\Zend_Validate_File_IsCompressed
Category
Zend  
Copyright
Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  

Constants

Constant  FALSE_TYPE = 'fileMimeTypeFalse'
Constant  NOT_DETECTED = 'fileMimeTypeNotDetected'
Constant  NOT_READABLE = 'fileMimeTypeNotReadable'

Properties

Propertyprotectedresource  $_finfo= ''

Finfo object to use

Details
Type
resource
Propertyprotectedboolean  $_headerCheck= 'false'

Option to allow header check

Default valuefalseDetails
Type
boolean
Propertyprotectedarray  $_magicFiles= 'array( '/usr/share/misc/magic''

If no $_ENV['MAGIC'] is set, try and autodiscover it based on common locations

Default valuearray( '/usr/share/misc/magic'Details
Type
array
Propertyprotectedstring|null  $_magicfile= ''

Magicfile to use

Details
Type
stringnull
Propertyprotectedarray  $_messageTemplates= 'array( self::FALSE_TYPE => "File '%value%' has a false mimetype of '%type%'"'

Error message templates
Default valuearray( self::FALSE_TYPE => "File '%value%' has a false mimetype of '%type%'"Details
Type
array
Propertyprotectedarray  $_messageVariables= 'array( 'type' => '_type' )'

Default valuearray( 'type' => '_type' )Details
Type
array
Propertyprotectedstring|null  $_mimetype= ''

Mimetypes

If null, there is no mimetype

Details
Type
stringnull
Propertyprotectedstring  $_type= ''

Details
Type
string

Methods

methodpublic__construct( string|array $mimetype ) : void

Sets validator options

Mimetype to accept

Parameters
Name Type Description
$mimetype string|array

MimeType

methodprotected_throw( string $file, string $errorType ) : false

Throws an error of the given type

Parameters
Name Type Description
$file string
$errorType string
Returns
Type Description
false
methodpublicaddMimeType( string|array $mimetype ) : \Zend_Validate_File_Extension

Adds the mimetypes

Parameters
Name Type Description
$mimetype string|array

The mimetypes to add for validation

Returns
Type Description
\Zend_Validate_File_Extension Provides a fluent interface
methodpublicenableHeaderCheck(  $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

Parameters
Name Type Description
$headerCheck
Returns
Type Description
\Zend_Validate_File_MimeType Provides fluid interface
methodpublicgetHeaderCheck( ) : boolean

Returns the Header Check option

Returns
Type Description
boolean
methodpublicgetMagicFile( ) : string

Returns the actual set magicfile

Returns
Type Description
string
methodpublicgetMimeType( boolean $asArray = false ) : string|array

Returns the set mimetypes

Parameters
Name Type Description
$asArray boolean

Returns the values as array, when false an concated string is returned

Returns
Type Description
string|array
methodpublicisValid( 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.

Parameters
Name Type Description
$value string

Real file to check for mimetype

$file array

File data from Zend_File_Transfer

Returns
Type Description
boolean
methodpublicsetMagicFile( 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

Parameters
Name Type Description
$file string
Returns
Type Description
\Zend_Validate_File_MimeType Provides fluid interface
Throws
Exception Description
\Zend_Validate_Exception When finfo can not read the magicfile
methodpublicsetMimeType( string|array $mimetype ) : \Zend_Validate_File_Extension

Sets the mimetypes

Parameters
Name Type Description
$mimetype string|array

The mimetypes to validate

Returns
Type Description
\Zend_Validate_File_Extension Provides a fluent interface
Documentation was generated by DocBlox 0.15.1.