File/Transfer/Adapter/Http.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 [email protected] 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_File_Transfer
- Version
- $Id: Http.php 25087 2012-11-06 21:15:45Z rob $
\Zend_File_Transfer_Adapter_Http
File transfer adapter class for the HTTP protocol
- Parent(s)
- \Zend_File_Transfer_Adapter_Abstract
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
Constants

FILTER
= 'FILTER'
- Inherited_from
- \Zend_File_Transfer_Adapter_Abstract::FILTER

VALIDATE
= 'VALIDATE'
- Inherited_from
- \Zend_File_Transfer_Adapter_Abstract::VALIDATE
Properties


array $_break = array()
array()
Details- Type
- array
- Inherited_from
- \Zend_File_Transfer_Adapter_Abstract::$$_break


$_callbackUploadProgress = 'uploadprogress_get_info'
'uploadprogress_get_info'
Details- Type
- n/a


array $_files = array()
Internal list of files This array looks like this: array(form => array( - Form is the name within the form or, if not set the filename name, - Original name of this file type, - Mime type of this file size, - Filesize in bytes tmp_name, - Internalally temporary filename for uploaded files error, - Error which has occured destination, - New destination for this file validators, - Set validator names for this file files - Set file names for this file ))
Inherited from: \Zend_File_Transfer_Adapter_Abstract::$$_filesarray()
Details- Type
- array
- Inherited_from
- \Zend_File_Transfer_Adapter_Abstract::$$_files


array $_filters = array()
array()
Details- Type
- array
- Inherited_from
- \Zend_File_Transfer_Adapter_Abstract::$$_filters


array $_loaders = array()
Plugin loaders for filter and validation chains
Inherited from: \Zend_File_Transfer_Adapter_Abstract::$$_loadersarray()
Details- Type
- array
- Inherited_from
- \Zend_File_Transfer_Adapter_Abstract::$$_loaders


array $_messages = array()
array()
Details- Type
- array
- Inherited_from
- \Zend_File_Transfer_Adapter_Abstract::$$_messages


$_options = array('ignoreNoFile' => false, 'useByteString' => true, 'magicFile' => null, 'detectInfos' => true)
Available options for file transfers
Inherited from: \Zend_File_Transfer_Adapter_Abstract::$$_optionsarray('ignoreNoFile' => false, 'useByteString' => true, 'magicFile' => null, 'detectInfos' => true)
Details- Type
- n/a
- Inherited_from
- \Zend_File_Transfer_Adapter_Abstract::$$_options


string $_tmpDir =
- Type
- string
- Inherited_from
- \Zend_File_Transfer_Adapter_Abstract::$$_tmpDir


\Zend_Translate $_translator =
- Type
- \Zend_Translate
- Inherited_from
- \Zend_File_Transfer_Adapter_Abstract::$$_translator


bool $_translatorDisabled = false
Is translation disabled?
Inherited from: \Zend_File_Transfer_Adapter_Abstract::$$_translatorDisabledfalse
Details- Type
- bool
- Inherited_from
- \Zend_File_Transfer_Adapter_Abstract::$$_translatorDisabled


array $_validators = array()
Internal list of validators
Inherited from: \Zend_File_Transfer_Adapter_Abstract::$$_validatorsarray()
Details- Type
- array
- Inherited_from
- \Zend_File_Transfer_Adapter_Abstract::$$_validators
Methods


__construct(array $options = array()) : void
Constructor for Http File Transfers
Name | Type | Description |
---|---|---|
$options | array | OPTIONAL Options to set |


_detectFileSize(array $value) : string
Internal method to detect the size of a file
Inherited from: \Zend_File_Transfer_Adapter_Abstract::_detectFileSize()Name | Type | Description |
---|---|---|
$value | array | File infos |
Type | Description |
---|---|
string | Filesize of given file |


_detectMimeType(array $value) : string
Internal method to detect the mime type of a file
Inherited from: \Zend_File_Transfer_Adapter_Abstract::_detectMimeType()Name | Type | Description |
---|---|---|
$value | array | File infos |
Type | Description |
---|---|
string | Mimetype of given file |


_filter(string | array $files = null) : boolean
Internal function to filter all given files
Inherited from: \Zend_File_Transfer_Adapter_Abstract::_filter()Name | Type | Description |
---|---|---|
$files | string | array | (Optional) Files to check |
Type | Description |
---|---|
boolean | False on error |


_getFiles(string | array $files, boolean $names = false, boolean $noexception = false) : array
Returns found files based on internal file array and given files
Inherited from: \Zend_File_Transfer_Adapter_Abstract::_getFiles()Name | Type | Description |
---|---|---|
$files | string | array | (Optional) Files to return |
$names | boolean | (Optional) Returns only names on true, else complete info |
$noexception | boolean | (Optional) Allows throwing an exception, otherwise returns an empty array |
Type | Description |
---|---|
array | Found files |
Exception | Description |
---|---|
\Zend_File_Transfer_Exception | On false filename |


_getFilterIdentifier(string $name) : string
Retrieve internal identifier for a named filter
Inherited from: \Zend_File_Transfer_Adapter_Abstract::_getFilterIdentifier()Name | Type | Description |
---|---|---|
$name | string |
Type | Description |
---|---|
string |


_getTmpDir() : string
Determine system TMP directory and detect if we have read access
Inherited from: \Zend_File_Transfer_Adapter_Abstract::_getTmpDir()Type | Description |
---|---|
string |
Exception | Description |
---|---|
\Zend_File_Transfer_Exception | if unable to determine directory |


_getValidatorIdentifier(string $name) : string
Retrieve internal identifier for a named validator
Inherited from: \Zend_File_Transfer_Adapter_Abstract::_getValidatorIdentifier()Name | Type | Description |
---|---|---|
$name | string |
Type | Description |
---|---|
string |


_isPathWriteable(string $path) : void
Tries to detect if we can read and write to the given path
Inherited from: \Zend_File_Transfer_Adapter_Abstract::_isPathWriteable()Name | Type | Description |
---|---|---|
$path | string |


_prepareFiles() : array
Prepare the $_FILES array to match the internal syntax of one file per entry
Type | Description |
---|---|
array |


_toByteString(integer $size) : string
Returns the formatted size
Inherited from: \Zend_File_Transfer_Adapter_Abstract::_toByteString()Name | Type | Description |
---|---|---|
$size | integer |
Type | Description |
---|---|
string |


addFile(string | array $file, string | array $validator = null, string | array $filter = null) : \Zend_File_Transfer_Adapter_Abstract
Name | Type | Description |
---|---|---|
$file | string | array | File to add |
$validator | string | array | Validators to use for this file, must be set before |
$filter | string | array | Filters to use for this file, must be set before |
Type | Description |
---|---|
\Zend_File_Transfer_Adapter_Abstract |
Exception | Description |
---|---|
\Zend_File_Transfer_Exception | Not implemented |


addFilter(string | array $filter, string | array $options = null, string | array $files = null) : \Zend_File_Transfer_Adapter
Adds a new filter for this class
Inherited from: \Zend_File_Transfer_Adapter_Abstract::addFilter()Name | Type | Description |
---|---|---|
$filter | string | array | Type of filter to add |
$options | string | array | Options to set for the filter |
$files | string | array | Files to limit this filter to |
Type | Description |
---|---|
\Zend_File_Transfer_Adapter |


addFilters(array $filters, string | array $files = null) : \Zend_File_Transfer_Adapter_Abstract
Add Multiple filters at once
Inherited from: \Zend_File_Transfer_Adapter_Abstract::addFilters()Name | Type | Description |
---|---|---|
$filters | array | |
$files | string | array |
Type | Description |
---|---|
\Zend_File_Transfer_Adapter_Abstract |


addPrefixPath(string $prefix, string $path, string $type = null) : \Zend_File_Transfer_Adapter_Abstract
Add prefix path for plugin loader
Inherited from: \Zend_File_Transfer_Adapter_Abstract::addPrefixPath()If no $type specified, assumes it is a base path for both filters and validators, and sets each according to the following rules: - filters: $prefix = $prefix . '_Filter' - validators: $prefix = $prefix . '_Validate'
Otherwise, the path prefix is set on the appropriate plugin loader.
Name | Type | Description |
---|---|---|
$prefix | string | |
$path | string | |
$type | string |
Type | Description |
---|---|
\Zend_File_Transfer_Adapter_Abstract |
Exception | Description |
---|---|
\Zend_File_Transfer_Exception | for invalid type |


addPrefixPaths(array $spec) : \Zend_File_Transfer_Exception
Add many prefix paths at once
Inherited from: \Zend_File_Transfer_Adapter_Abstract::addPrefixPaths()Name | Type | Description |
---|---|---|
$spec | array |
Type | Description |
---|---|
\Zend_File_Transfer_Exception |


addType(string | array $type, string | array $validator = null, string | array $filter = null) : \Zend_File_Transfer_Adapter_Abstract
Adds one or more type of files
Inherited from: \Zend_File_Transfer_Adapter_Abstract::addType()Name | Type | Description |
---|---|---|
$type | string | array | Type of files to add |
$validator | string | array | Validators to use for this file, must be set before |
$filter | string | array | Filters to use for this file, must be set before |
Type | Description |
---|---|
\Zend_File_Transfer_Adapter_Abstract |
Exception | Description |
---|---|
\Zend_File_Transfer_Exception | Not implemented |


addValidator(string | array $validator, boolean $breakChainOnFailure = false, string | array $options = null, string | array $files = null) : \Zend_File_Transfer_Adapter
Adds a new validator for this class
Inherited from: \Zend_File_Transfer_Adapter_Abstract::addValidator()Name | Type | Description |
---|---|---|
$validator | string | array | Type of validator to add |
$breakChainOnFailure | boolean | If the validation chain should stop an failure |
$options | string | array | Options to set for the validator |
$files | string | array | Files to limit this validator to |
Type | Description |
---|---|
\Zend_File_Transfer_Adapter |


addValidators(array $validators, string | array $files = null) : \Zend_File_Transfer_Adapter_Abstract
Add Multiple validators at once
Inherited from: \Zend_File_Transfer_Adapter_Abstract::addValidators()Name | Type | Description |
---|---|---|
$validators | array | |
$files | string | array |
Type | Description |
---|---|
\Zend_File_Transfer_Adapter_Abstract |


clearFilters() : \Zend_File_Transfer_Adapter_Abstract
Type | Description |
---|---|
\Zend_File_Transfer_Adapter_Abstract |


clearValidators() : \Zend_File_Transfer_Adapter_Abstract
Remove an individual validator
Type | Description |
---|---|
\Zend_File_Transfer_Adapter_Abstract |


getDestination(null | string | array $files = null) : null | string | array
Retrieve destination directory value
Inherited from: \Zend_File_Transfer_Adapter_Abstract::getDestination()Name | Type | Description |
---|---|---|
$files | null | string | array |
Type | Description |
---|---|
null | string | array |


getFile() : array
Type | Description |
---|---|
array | List of set files |
Exception | Description |
---|---|
\Zend_File_Transfer_Exception | Not implemented |


getFileInfo(string $file = null) : array
Retrieve additional internal file informations for files
Inherited from: \Zend_File_Transfer_Adapter_Abstract::getFileInfo()Name | Type | Description |
---|---|---|
$file | string | (Optional) File to get informations for |
Type | Description |
---|---|
array |


getFileName( $file = null, boolean $path = true) : string | array
Retrieves the filename of transferred files.
Inherited from: \Zend_File_Transfer_Adapter_Abstract::getFileName()Name | Type | Description |
---|---|---|
$file | ||
$path | boolean | (Optional) Should the path also be returned ? |
Type | Description |
---|---|
string | array |


getFileSize(string | array $files = null) : string | array
Returns the real filesize of the file
Inherited from: \Zend_File_Transfer_Adapter_Abstract::getFileSize()Name | Type | Description |
---|---|---|
$files | string | array | Files to get the filesize from |
Type | Description |
---|---|
string | array | Filesize |
Exception | Description |
---|---|
\Zend_File_Transfer_Exception | When the file does not exist |


getFilter(string $name) : \Zend_Filter_Interface | null
Retrieve individual filter
Inherited from: \Zend_File_Transfer_Adapter_Abstract::getFilter()Name | Type | Description |
---|---|---|
$name | string |
Type | Description |
---|---|
\Zend_Filter_Interface | null |


getFilters(string | array $files = null) : array
Name | Type | Description |
---|---|---|
$files | string | array | (Optional) Returns the filter for this files |
Type | Description |
---|---|
array | List of set filters |
Exception | Description |
---|---|
\Zend_File_Transfer_Exception | When file not found |


getHash(string $hash = 'crc32', string | array $files = null) : string | array
Returns the hash for a given file
Inherited from: \Zend_File_Transfer_Adapter_Abstract::getHash()Name | Type | Description |
---|---|---|
$hash | string | Hash algorithm to use |
$files | string | array | Files to return the hash for |
Type | Description |
---|---|
string | array | Hashstring |
Exception | Description |
---|---|
\Zend_File_Transfer_Exception | On unknown hash algorithm |


getMessages() : array
Returns found validation messages
Inherited from: \Zend_File_Transfer_Adapter_Abstract::getMessages()Type | Description |
---|---|
array |


getMimeType(string | array $files = null) : string | array
Returns the real mimetype of the file Uses fileinfo, when not available mime_magic and as last fallback a manual given mimetype
Inherited from: \Zend_File_Transfer_Adapter_Abstract::getMimeType()Name | Type | Description |
---|---|---|
$files | string | array | Files to get the mimetype from |
Type | Description |
---|---|
string | array | MimeType |
Exception | Description |
---|---|
\Zend_File_Transfer_Exception | When the file does not exist |


getOptions(array $files = null) : array
Returns set options for adapters or files
Inherited from: \Zend_File_Transfer_Adapter_Abstract::getOptions()Name | Type | Description |
---|---|---|
$files | array | (Optional) Files to return the options for |
Type | Description |
---|---|
array | Options for given files |


getPluginLoader(string $type) : \Zend_Loader_PluginLoader
Retrieve plugin loader for validator or filter chain
Inherited from: \Zend_File_Transfer_Adapter_Abstract::getPluginLoader()Instantiates with default rules if none available for that type. Use 'filter' or 'validate' for $type.
Name | Type | Description |
---|---|---|
$type | string |
Type | Description |
---|---|
\Zend_Loader_PluginLoader |
Exception | Description |
---|---|
\Zend_File_Transfer_Exception | on invalid type. |


getProgress(string $id = null) : array | null
Returns the actual progress of file up-/downloads
Name | Type | Description |
---|---|---|
$id | string | The upload to get the progress for |
Type | Description |
---|---|
array | null |


getTranslator() : \Zend_Translate_Adapter | null
Retrieve localization translator object
Inherited from: \Zend_File_Transfer_Adapter_Abstract::getTranslator()Type | Description |
---|---|
\Zend_Translate_Adapter | null |


getType() : array
Type | Description |
---|---|
array | List of set types |
Exception | Description |
---|---|
\Zend_File_Transfer_Exception | Not implemented |


getValidator(string $name) : \Zend_Validate_Interface | null
Retrieve individual validator
Inherited from: \Zend_File_Transfer_Adapter_Abstract::getValidator()Name | Type | Description |
---|---|---|
$name | string |
Type | Description |
---|---|
\Zend_Validate_Interface | null |


getValidators(string | array $files = null) : null | array
Returns all set validators
Inherited from: \Zend_File_Transfer_Adapter_Abstract::getValidators()Name | Type | Description |
---|---|---|
$files | string | array | (Optional) Returns the validator for this files |
Type | Description |
---|---|
null | array | List of set validators |


hasErrors() : boolean
Are there errors registered?
Inherited from: \Zend_File_Transfer_Adapter_Abstract::hasErrors()Type | Description |
---|---|
boolean |


hasFilter(string $name) : bool
Determine if a given filter has already been registered
Inherited from: \Zend_File_Transfer_Adapter_Abstract::hasFilter()Name | Type | Description |
---|---|---|
$name | string |
Type | Description |
---|---|
bool |


hasValidator(string $name) : bool
Determine if a given validator has already been registered
Inherited from: \Zend_File_Transfer_Adapter_Abstract::hasValidator()Name | Type | Description |
---|---|---|
$name | string |
Type | Description |
---|---|
bool |


isApcAvailable() : boolean
Checks the APC extension for progress information
Type | Description |
---|---|
boolean |


isFiltered(string | array $files = null) : bool
Checks if the file was already filtered
Name | Type | Description |
---|---|---|
$files | string | array | (Optional) Files to check |
Type | Description |
---|---|
bool |


isReceived(string | array $files = null) : bool
Checks if the file was already received
Name | Type | Description |
---|---|---|
$files | string | array | (Optional) Files to check |
Type | Description |
---|---|
bool |


isSent( $files = null) : bool
Checks if the file was already sent
Name | Type | Description |
---|---|---|
$files |
Type | Description |
---|---|
bool |
Exception | Description |
---|---|
\Zend_File_Transfer_Exception | Not implemented |


isUploadProgressAvailable() : boolean
Checks the UploadProgress extension for progress information
Type | Description |
---|---|
boolean |


isUploaded( $files = null) : bool
Has a file been uploaded ?
Name | Type | Description |
---|---|---|
$files |
Type | Description |
---|---|
bool |


isValid(string | array $files = null) : boolean
Checks if the files are valid
Name | Type | Description |
---|---|---|
$files | string | array | (Optional) Files to check |
Type | Description |
---|---|
boolean | True if all checks are valid |


receive(string | array $files = null) : bool
Receive the file from the client (Upload)
Name | Type | Description |
---|---|---|
$files | string | array | (Optional) Files to receive |
Type | Description |
---|---|
bool |


removeFilter(string $name) : \Zend_File_Transfer_Adapter_Abstract
Remove an individual filter
Inherited from: \Zend_File_Transfer_Adapter_Abstract::removeFilter()Name | Type | Description |
---|---|---|
$name | string |
Type | Description |
---|---|
\Zend_File_Transfer_Adapter_Abstract |


removeValidator(string $name) : \Zend_File_Transfer_Adapter_Abstract
Remove an individual validator
Name | Type | Description |
---|---|---|
$name | string |
Type | Description |
---|---|
\Zend_File_Transfer_Adapter_Abstract |


send(string | array $options = null) : void
Send the file to the client (Download)
Name | Type | Description |
---|---|---|
$options | string | array | Options for the file(s) to send |
Exception | Description |
---|---|
\Zend_File_Transfer_Exception | Not implemented |


setDestination(string $destination, string | array $files = null) : \Zend_File_Transfer_Abstract
Sets a new destination for the given files
Inherited from: \Zend_File_Transfer_Adapter_Abstract::setDestination()Name | Type | Description |
---|---|---|
$destination | string | New destination directory |
$files | string | array | Files to set the new destination for |
Type | Description |
---|---|
\Zend_File_Transfer_Abstract |
Exception | Description |
---|---|
\Zend_File_Transfer_Exception | when the given destination is not a directory or does not exist |


setDisableTranslator(bool $flag) : \Zend_File_Transfer_Abstract
Indicate whether or not translation should be disabled
Inherited from: \Zend_File_Transfer_Adapter_Abstract::setDisableTranslator()Name | Type | Description |
---|---|---|
$flag | bool |
Type | Description |
---|---|
\Zend_File_Transfer_Abstract |


setFilters( $filters, string | array $files = null) : \Zend_File_Transfer_Adapter
Sets a filter for the class, erasing all previous set
Inherited from: \Zend_File_Transfer_Adapter_Abstract::setFilters()Name | Type | Description |
---|---|---|
$filters | ||
$files | string | array | Files to limit this filter to |
Type | Description |
---|---|
\Zend_File_Transfer_Adapter |


setOptions(array $options = array(), array $files = null) : void
Sets Options for adapters
Inherited from: \Zend_File_Transfer_Adapter_Abstract::setOptions()Name | Type | Description |
---|---|---|
$options | array | Options to set |
$files | array | (Optional) Files to set the options for |


setPluginLoader(\Zend_Loader_PluginLoader_Interface $loader, string $type) : \Zend_File_Transfer_Adapter_Abstract
Set plugin loader to use for validator or filter chain
Inherited from: \Zend_File_Transfer_Adapter_Abstract::setPluginLoader()Name | Type | Description |
---|---|---|
$loader | \Zend_Loader_PluginLoader_Interface | |
$type | string | 'filter', or 'validate' |
Type | Description |
---|---|
\Zend_File_Transfer_Adapter_Abstract |
Exception | Description |
---|---|
\Zend_File_Transfer_Exception | on invalid type |


setTranslator(\Zend_Translate | null $translator = null) : \Zend_File_Transfer_Abstract
Set translator object for localization
Inherited from: \Zend_File_Transfer_Adapter_Abstract::setTranslator()Name | Type | Description |
---|---|---|
$translator | \Zend_Translate | null |
Type | Description |
---|---|
\Zend_File_Transfer_Abstract |


setValidators( $validators, string | array $files = null) : \Zend_File_Transfer_Adapter
Sets a validator for the class, erasing all previous set
Name | Type | Description |
---|---|---|
$validators | ||
$files | string | array | Files to limit this validator to |
Type | Description |
---|---|
\Zend_File_Transfer_Adapter |


translatorIsDisabled() : bool
Is translation disabled?
Inherited from: \Zend_File_Transfer_Adapter_Abstract::translatorIsDisabled()Type | Description |
---|---|
bool |