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) : void
Sets 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
ParametersName | Type | Description |
---|---|---|
$options | integer | array | Options for the adapter |
_fromByteString(string $size) : integer
Returns the unformatted size
Parameters
Returns
Name | Type | Description |
---|---|---|
$size | string |
Type | Description |
---|---|
integer |
_setSize(int $size) : \Zend_Validate_File_Size
Set current size
Parameters
Returns
Name | Type | Description |
---|---|---|
$size | int |
Type | Description |
---|---|
\Zend_Validate_File_Size |
_throw(string $file, string $errorType) : false
Throws an error of the given type
Parameters
Returns
Name | Type | Description |
---|---|---|
$file | string | |
$errorType | string |
Type | Description |
---|---|
false |
_toByteString(integer $size) : string
Returns the formatted size
Parameters
Returns
Name | Type | Description |
---|---|---|
$size | integer |
Type | Description |
---|---|
string |
getMax(bool $raw = false) : integer | string
Returns 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 | string
Returns 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) : boolean
Defined 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).
ParametersName | 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_StringLength
Sets 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_Size
Sets 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) : integer
Returns the minimum filesize
Parameters
Returns
Name | Type | Description |
---|---|---|
$byteString | boolean | Use bytestring ? |
Type | Description |
---|---|
integer |