API Documentation

Validate/File/MimeType.php

Includes Classes 
category
Zend
copyright
Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
license
http://framework.zend.com/license/new-bsd New BSD License
package
Zend_Validate
version
$Id: MimeType.php 22697 2010-07-26 21:14:47Z alexander $
Classes
Zend_Validate_File_MimeType

Description

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.

Zend_Validate_File_MimeType

Extends from
Zend_Validate_Abstract
category
Zend
copyright
Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
license
http://framework.zend.com/license/new-bsd New BSD License
package
Zend_Validate
Constants
FALSE_TYPE
NOT_DETECTED
NOT_READABLE
Properties
$_messageTemplates
$_messageVariables
$_type
$_mimetype
$_magicfile
$_finfo
$_magicFiles
$_headerCheck
Methods
__construct
getMagicFile
setMagicFile
getHeaderCheck
enableHeaderCheck
getMimeType
setMimeType
addMimeType
isValid
_throw

Description

Validator for the mime type of a file

Constants

FALSE_TYPE

 FALSE_TYPE = 'fileMimeTypeFalse'

Details

value
fileMimeTypeFalse

NOT_DETECTED

 NOT_DETECTED = 'fileMimeTypeNotDetected'

Details

value
fileMimeTypeNotDetected

NOT_READABLE

 NOT_READABLE = 'fileMimeTypeNotReadable'

Details

value
fileMimeTypeNotReadable

Properties

$_finfo

resource $_finfo = ''

Finfo object to use

Details

$_finfo
resource
visibility
protected
default
final
false
static
false

$_headerCheck

boolean $_headerCheck = 'false'

Option to allow header check

Details

$_headerCheck
boolean
visibility
protected
default
false
final
false
static
false

$_magicFiles

array $_magicFiles = 'array'

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

Details

$_magicFiles
array
visibility
protected
default
array
final
false
static
false

$_magicfile

string|null $_magicfile = ''

Magicfile to use

Details

$_magicfile
string|null
visibility
protected
default
final
false
static
false

$_messageTemplates

array $_messageTemplates = 'array'

Details

$_messageTemplates
array
Error message templates
visibility
protected
default
array
final
false
static
false

$_messageVariables

array $_messageVariables = 'array'

Details

$_messageVariables
array
visibility
protected
default
array
final
false
static
false

$_mimetype

string|null $_mimetype = ''

Mimetypes

If null, there is no mimetype

Details

$_mimetype
string|null
visibility
protected
default
final
false
static
false

$_type

string $_type = ''

Details

$_type
string
visibility
protected
default
final
false
static
false

Methods

__construct

__construct( string|array $mimetype ) : void

Sets validator options

Mimetype to accept

Arguments
$mimetype
stringarray
MimeType
Details
visibility
public
final
false
static
false

_throw

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

Throws an error of the given type

Arguments
$file
string
$errorType
string
Output
false
Details
visibility
protected
final
false
static
false

addMimeType

addMimeType( string|array $mimetype ) : Zend_Validate_File_Extension

Adds the mimetypes

Arguments
$mimetype
stringarray
The mimetypes to add for validation
Output
Zend_Validate_File_Extension
Provides a fluent interface
Details
visibility
public
final
false
static
false

enableHeaderCheck

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

Arguments
$headerCheck
Output
Zend_Validate_File_MimeType
Provides fluid interface
Details
visibility
public
final
false
static
false

getHeaderCheck

getHeaderCheck( ) : boolean

Returns the Header Check option

Output
boolean
Details
visibility
public
final
false
static
false

getMagicFile

getMagicFile( ) : string

Returns the actual set magicfile

Output
string
Details
visibility
public
final
false
static
false

getMimeType

getMimeType( boolean $asArray = false ) : string|array

Returns the set mimetypes

Arguments
$asArray
boolean
Returns the values as array, when false an concated string is returned
Output
string|array
Details
visibility
public
final
false
static
false

isValid

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.

Arguments
$value
string
Real file to check for mimetype
$file
array
File data from Zend_File_Transfer
Output
boolean
Details
visibility
public
final
false
static
false

setMagicFile

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

Arguments
$file
string
Output
Zend_Validate_File_MimeType
Provides fluid interface
Details
visibility
public
final
false
static
false
throws
When finfo can not read the magicfile

setMimeType

setMimeType( string|array $mimetype ) : Zend_Validate_File_Extension

Sets the mimetypes

Arguments
$mimetype
stringarray
The mimetypes to validate
Output
Zend_Validate_File_Extension
Provides a fluent interface
Details
visibility
public
final
false
static
false
Documentation was generated by DocBlox.