Validate/File/Upload.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-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_Validate
- Version
- $Id: Upload.php 24959 2012-06-15 13:51:04Z adamlundrigan $
\Zend_Validate_File_Upload
Package: Zend\ValidateValidator for the maximum size of a file up to a max of 2GB
- Parent(s)
- \Zend_Validate_Abstract
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
Constants


INI_SIZE
= 'fileUploadErrorIniSize'

FORM_SIZE
= 'fileUploadErrorFormSize'

PARTIAL
= 'fileUploadErrorPartial'

NO_FILE
= 'fileUploadErrorNoFile'

NO_TMP_DIR
= 'fileUploadErrorNoTmpDir'

CANT_WRITE
= 'fileUploadErrorCantWrite'

EXTENSION
= 'fileUploadErrorExtension'

ATTACK
= 'fileUploadErrorAttack'

FILE_NOT_FOUND
= 'fileUploadErrorFileNotFound'

UNKNOWN
= 'fileUploadErrorUnknown'Properties



array $_messageTemplates = array(self::INI_SIZE => "File '%value%' exceeds the defined ini size", self::FORM_SIZE => "File '%value%' exceeds the defined form size", self::PARTIAL => "File '%value%' was only partially uploaded", self::NO_FILE => "File '%value%' was not uploaded", self::NO_TMP_DIR => "No temporary directory was found for file '%value%'", self::CANT_WRITE => "File '%value%' can't be written", self::EXTENSION => "A PHP extension returned an error while uploading the file '%value%'", self::ATTACK => "File '%value%' was illegally uploaded. This could be a possible attack", self::FILE_NOT_FOUND => "File '%value%' was not found", self::UNKNOWN => "Unknown error while uploading file '%value%'")Validation failure message template definitions
Default valuearray(self::INI_SIZE => "File '%value%' exceeds the defined ini size", self::FORM_SIZE => "File '%value%' exceeds the defined form size", self::PARTIAL => "File '%value%' was only partially uploaded", self::NO_FILE => "File '%value%' was not uploaded", self::NO_TMP_DIR => "No temporary directory was found for file '%value%'", self::CANT_WRITE => "File '%value%' can't be written", self::EXTENSION => "A PHP extension returned an error while uploading the file '%value%'", self::ATTACK => "File '%value%' was illegally uploaded. This could be a possible attack", self::FILE_NOT_FOUND => "File '%value%' was not found", self::UNKNOWN => "Unknown error while uploading file '%value%'")Details- Type
- array
Methods



__construct(array | \Zend_Config $files = array()) : voidThe array $files must be given in syntax of Zend_File_Transfer to be checked
If no files are given the $_FILES array will be used automatically.
NOTE: This validator will only work with HTTP POST uploads!
Parameters| Name | Type | Description |
|---|
| $files | array | \Zend_Config | Array of files in syntax of Zend_File_Transfer |
|---|



__get(string $property) : mixedinheritedMagic function returns the value of the requested property, if and only if it is the value or a
message variable.
Inherited from:
\Zend_Validate_Abstract::__get() Parameters| Name | Type | Description |
|---|
| $property | string | |
|---|
ReturnsThrows 


_createMessage(string $messageKey, string $value) : stringReturns null if and only if $messageKey does not correspond to an existing template.
If a translator is available and a translation exists for $messageKey,
the translation will be used.
Parameters| Name | Type | Description |
|---|
| $messageKey | string | |
|---|
| $value | string | |
|---|
Returns


_error(string $messageKey, string $value = null) : voidParameters| Name | Type | Description |
|---|
| $messageKey | string | |
|---|
| $value | string | OPTIONAL |
|---|



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


getMessages() : arrayThe array keys are validation failure message identifiers,
and the array values are the corresponding human-readable message strings.
If isValid() was never called or if the most recent isValid() call
returned true, then this method returns an empty array.
Returns


isValid(string $value, $file = null) : booleanDefined by Zend_Validate_Interface
Returns true if and only if the file was uploaded without errors
Parameters| Name | Type | Description |
|---|
| $value | string | Single file to check for upload errors, when giving null the $_FILES array
from initialization will be used
|
|---|
| $file | | |
|---|
ReturnsThrows


setFiles(array $files = array()) : \Zend_Validate_File_UploadSets the files to be checked
Parameters| Name | Type | Description |
|---|
| $files | array | The files to check in syntax of Zend_File_Transfer |
|---|
Returns 


setMessage(string $messageString, string $messageKey = null) : \Zend_Validate_AbstractParameters| Name | Type | Description |
|---|
| $messageString | string | |
|---|
| $messageKey | string | OPTIONAL |
|---|
ReturnsThrows 


setMessages(array $messages) : \Zend_Validate_AbstractinheritedSets validation failure message templates given as an array, where the array keys are the message keys,
and the array values are the message template strings.
Inherited from:
\Zend_Validate_Abstract::setMessages() Parameters| Name | Type | Description |
|---|
| $messages | array | |
|---|
Returns