Validate/File/Size.php
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-2014 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_Validate
- Version
- $Id$
\Zend_Validate_File_Size
Package: Zend_Validate









Returns



Validator for the maximum size of a file up to a max of 2GB
- Parent(s)
- \Zend_Validate_Abstract
- Children
- \Zend_Validate_File_FilesSize
- Category
- Zend
- Copyright
- Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
Constants
Properties

array $_messageTemplates = array(self::TOO_BIG => "Maximum allowed size for file '%value%' is '%max%' but '%size%' detected", self::TOO_SMALL => "Minimum expected size for file '%value%' is '%min%' but '%size%' detected", self::NOT_FOUND => "File '%value%' is not readable or does not exist")Error message templates
Default value
array(self::TOO_BIG => "Maximum allowed size for file '%value%' is '%max%' but '%size%' detected", self::TOO_SMALL => "Minimum expected size for file '%value%' is '%min%' but '%size%' detected", self::NOT_FOUND => "File '%value%' is not readable or does not exist")Details- Type
- array

array $_messageVariables = array('min' => '_min', 'max' => '_max', 'size' => '_size')Error message template variables
Default value
array('min' => '_min', 'max' => '_max', 'size' => '_size')Details- Type
- array
Methods

__construct(integer | array $options) : voidSets validator options
If $options is a integer, it will be used as maximum filesize
As Array is accepts the following keys:
'min': Minimum filesize
'max': Maximum filesize
'bytestring': Use bytestring or real size for messages
Parameters| Name | Type | Description |
|---|---|---|
| $options | integer | array | Options for the adapter |

_fromByteString(string $size) : integerReturns the unformatted size
Parameters
Returns
| Name | Type | Description |
|---|---|---|
| $size | string |
| Type | Description |
|---|---|
| integer |

_setSize(int $size) : \Zend_Validate_File_SizeSet current size
Parameters
Returns
| Name | Type | Description |
|---|---|---|
| $size | int |
| Type | Description |
|---|---|
| \Zend_Validate_File_Size |

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

_toByteString(integer $size) : stringReturns the formatted size
Parameters
Returns
| Name | Type | Description |
|---|---|---|
| $size | integer |
| Type | Description |
|---|---|
| string |

getMax(bool $raw = false) : integer | stringReturns the maximum filesize
Parameters
Returns
| Name | Type | Description |
|---|---|---|
| $raw | bool | Whether or not to force return of the raw value (defaults off) |
| Type | Description |
|---|---|
| integer | string |

getMin(bool $raw = false) : integer | stringReturns the minimum filesize
Parameters
Returns
| Name | Type | Description |
|---|---|---|
| $raw | bool | Whether or not to force return of the raw value (defaults off) |
| Type | Description |
|---|---|
| integer | string |

isValid(string $value, array $file = null) : booleanDefined by Zend_Validate_Interface
Returns true if and only if the filesize of $value is at least min and
not bigger than max (when max is not null).
Parameters| Name | Type | Description |
|---|---|---|
| $value | string | Real file to check for size |
| $file | array | File data from Zend_File_Transfer |
| Type | Description |
|---|---|
| boolean |

setMax(integer $max) : \Zend_Validate_StringLengthSets the maximum filesize
Parameters
Returns
Throws
| Name | Type | Description |
|---|---|---|
| $max | integer | The maximum filesize |
| Type | Description |
|---|---|
| \Zend_Validate_StringLength | Provides a fluent interface |
| Exception | Description |
|---|---|
| \Zend_Validate_Exception | When max is smaller than min |

setMin(integer $min) : \Zend_Validate_File_SizeSets the minimum filesize
Parameters
Returns
Throws
| Name | Type | Description |
|---|---|---|
| $min | integer | The minimum filesize |
| Type | Description |
|---|---|
| \Zend_Validate_File_Size | Provides a fluent interface |
| Exception | Description |
|---|---|
| \Zend_Validate_Exception | When min is greater than max |

setUseByteString(boolean $byteString = true) : integerReturns the minimum filesize
Parameters
Returns
| Name | Type | Description |
|---|---|---|
| $byteString | boolean | Use bytestring ? |
| Type | Description |
|---|---|
| integer |