File/Transfer/Adapter/Http.php

Show: inherited
Table of Contents

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

Package: Zend\File\Transfer

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

Constant  FILTER = 'FILTER'
Constant  VALIDATE = 'VALIDATE'

Properties

Propertyprotectedarray $_break = array()
inherited

Internal list of breaks

Inherited from: \Zend_File_Transfer_Adapter_Abstract::$$_break
Default valuearray()Details
Type
array
Inherited_from
\Zend_File_Transfer_Adapter_Abstract::$$_break  
Propertyprotected$_callbackApc = 'apc_fetch'
static
Default value'apc_fetch'Details
Type
n/a
Propertyprotected$_callbackUploadProgress = 'uploadprogress_get_info'
static
Default value'uploadprogress_get_info'Details
Type
n/a
Propertyprotectedarray $_files = array()
inherited

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::$$_files
Default valuearray()Details
Type
array
Inherited_from
\Zend_File_Transfer_Adapter_Abstract::$$_files  
Propertyprotectedarray $_filters = array()
inherited

Internal list of filters

Inherited from: \Zend_File_Transfer_Adapter_Abstract::$$_filters
Default valuearray()Details
Type
array
Inherited_from
\Zend_File_Transfer_Adapter_Abstract::$$_filters  
Propertyprotectedarray $_loaders = array()
inherited

Plugin loaders for filter and validation chains

Inherited from: \Zend_File_Transfer_Adapter_Abstract::$$_loaders
Default valuearray()Details
Type
array
Inherited_from
\Zend_File_Transfer_Adapter_Abstract::$$_loaders  
Propertyprotectedarray $_messages = array()
inherited

Internal list of messages

Inherited from: \Zend_File_Transfer_Adapter_Abstract::$$_messages
Default valuearray()Details
Type
array
Inherited_from
\Zend_File_Transfer_Adapter_Abstract::$$_messages  
Propertyprotected$_options = array('ignoreNoFile' => false, 'useByteString' => true, 'magicFile' => null, 'detectInfos' => true)
inherited

Available options for file transfers

Inherited from: \Zend_File_Transfer_Adapter_Abstract::$$_options
Default valuearray('ignoreNoFile' => false, 'useByteString' => true, 'magicFile' => null, 'detectInfos' => true)Details
Type
n/a
Inherited_from
\Zend_File_Transfer_Adapter_Abstract::$$_options  
Propertyprotectedstring $_tmpDir =
inherited

TMP directory

Inherited from: \Zend_File_Transfer_Adapter_Abstract::$$_tmpDir
Details
Type
string
Inherited_from
\Zend_File_Transfer_Adapter_Abstract::$$_tmpDir  
Propertyprotected\Zend_Translate $_translator =
Propertyprotectedbool $_translatorDisabled = false
inherited

Is translation disabled?

Inherited from: \Zend_File_Transfer_Adapter_Abstract::$$_translatorDisabled
Default valuefalseDetails
Type
bool
Inherited_from
\Zend_File_Transfer_Adapter_Abstract::$$_translatorDisabled  
Propertyprotectedarray $_validators = array()
inherited

Internal list of validators

Inherited from: \Zend_File_Transfer_Adapter_Abstract::$$_validators
Default valuearray()Details
Type
array
Inherited_from
\Zend_File_Transfer_Adapter_Abstract::$$_validators  

Methods

methodpublic__construct(array $options = array()) : void

Constructor for Http File Transfers

Parameters
Name Type Description
$options array

OPTIONAL Options to set

methodprotected_detectFileSize(array $value) : string
inherited

Internal method to detect the size of a file

Inherited from: \Zend_File_Transfer_Adapter_Abstract::_detectFileSize()
Parameters
Name Type Description
$value array

File infos

Returns
Type Description
string Filesize of given file
methodprotected_detectMimeType(array $value) : string
inherited

Internal method to detect the mime type of a file

Inherited from: \Zend_File_Transfer_Adapter_Abstract::_detectMimeType()
Parameters
Name Type Description
$value array

File infos

Returns
Type Description
string Mimetype of given file
methodprotected_filter(string | array $files = null) : boolean
inherited

Internal function to filter all given files

Inherited from: \Zend_File_Transfer_Adapter_Abstract::_filter()
Parameters
Name Type Description
$files string | array

(Optional) Files to check

Returns
Type Description
boolean False on error
methodprotected_getFiles(string | array $files, boolean $names = false, boolean $noexception = false) : array
inherited

Returns found files based on internal file array and given files

Inherited from: \Zend_File_Transfer_Adapter_Abstract::_getFiles()
Parameters
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

Returns
Type Description
array Found files
Throws
Exception Description
\Zend_File_Transfer_Exception On false filename
methodprotected_getFilterIdentifier(string $name) : string
inherited

Retrieve internal identifier for a named filter

Inherited from: \Zend_File_Transfer_Adapter_Abstract::_getFilterIdentifier()
Parameters
Name Type Description
$name string
Returns
Type Description
string
methodprotected_getTmpDir() : string
inherited

Determine system TMP directory and detect if we have read access

Inherited from: \Zend_File_Transfer_Adapter_Abstract::_getTmpDir()
Returns
Type Description
string
Throws
Exception Description
\Zend_File_Transfer_Exception if unable to determine directory
methodprotected_getValidatorIdentifier(string $name) : string
inherited

Retrieve internal identifier for a named validator

Inherited from: \Zend_File_Transfer_Adapter_Abstract::_getValidatorIdentifier()
Parameters
Name Type Description
$name string
Returns
Type Description
string
methodprotected_isPathWriteable(string $path) : void
inherited

Tries to detect if we can read and write to the given path

Inherited from: \Zend_File_Transfer_Adapter_Abstract::_isPathWriteable()
Parameters
Name Type Description
$path string
methodprotected_prepareFiles() : array

Prepare the $_FILES array to match the internal syntax of one file per entry

Returns
Type Description
array
methodprotected_toByteString(integer $size) : string
staticinherited

Returns the formatted size

Inherited from: \Zend_File_Transfer_Adapter_Abstract::_toByteString()
Parameters
Name Type Description
$size integer
Returns
Type Description
string
methodpublicaddFile(string | array $file, string | array $validator = null, string | array $filter = null) : \Zend_File_Transfer_Adapter_Abstract
inherited

Adds one or more files

Inherited from: \Zend_File_Transfer_Adapter_Abstract::addFile()
Parameters
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

Returns
Type Description
\Zend_File_Transfer_Adapter_Abstract
Throws
Exception Description
\Zend_File_Transfer_Exception Not implemented
methodpublicaddFilter(string | array $filter, string | array $options = null, string | array $files = null) : \Zend_File_Transfer_Adapter
inherited

Adds a new filter for this class

Inherited from: \Zend_File_Transfer_Adapter_Abstract::addFilter()
Parameters
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

Returns
Type Description
\Zend_File_Transfer_Adapter
methodpublicaddFilters(array $filters, string | array $files = null) : \Zend_File_Transfer_Adapter_Abstract
inherited

Add Multiple filters at once

Inherited from: \Zend_File_Transfer_Adapter_Abstract::addFilters()
Parameters
Name Type Description
$filters array
$files string | array
Returns
Type Description
\Zend_File_Transfer_Adapter_Abstract
methodpublicaddPrefixPath(string $prefix, string $path, string $type = null) : \Zend_File_Transfer_Adapter_Abstract
inherited

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.

Parameters
Name Type Description
$prefix string
$path string
$type string
Returns
Type Description
\Zend_File_Transfer_Adapter_Abstract
Throws
Exception Description
\Zend_File_Transfer_Exception for invalid type
methodpublicaddPrefixPaths(array $spec) : \Zend_File_Transfer_Exception
inherited

Add many prefix paths at once

Inherited from: \Zend_File_Transfer_Adapter_Abstract::addPrefixPaths()
Parameters
Name Type Description
$spec array
Returns
Type Description
\Zend_File_Transfer_Exception
methodpublicaddType(string | array $type, string | array $validator = null, string | array $filter = null) : \Zend_File_Transfer_Adapter_Abstract
inherited

Adds one or more type of files

Inherited from: \Zend_File_Transfer_Adapter_Abstract::addType()
Parameters
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

Returns
Type Description
\Zend_File_Transfer_Adapter_Abstract
Throws
Exception Description
\Zend_File_Transfer_Exception Not implemented
methodpublicaddValidator(string | array $validator, boolean $breakChainOnFailure = false, string | array $options = null, string | array $files = null) : \Zend_File_Transfer_Adapter
inherited

Adds a new validator for this class

Inherited from: \Zend_File_Transfer_Adapter_Abstract::addValidator()
Parameters
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

Returns
Type Description
\Zend_File_Transfer_Adapter
methodpublicaddValidators(array $validators, string | array $files = null) : \Zend_File_Transfer_Adapter_Abstract
inherited

Add Multiple validators at once

Inherited from: \Zend_File_Transfer_Adapter_Abstract::addValidators()
Parameters
Name Type Description
$validators array
$files string | array
Returns
Type Description
\Zend_File_Transfer_Adapter_Abstract
methodpublicclearFilters() : \Zend_File_Transfer_Adapter_Abstract
inherited

Remove all filters

Inherited from: \Zend_File_Transfer_Adapter_Abstract::clearFilters()
Returns
Type Description
\Zend_File_Transfer_Adapter_Abstract
methodpublicclearValidators() : \Zend_File_Transfer_Adapter_Abstract

Remove an individual validator

Returns
Type Description
\Zend_File_Transfer_Adapter_Abstract
methodpublicgetDestination(null | string | array $files = null) : null | string | array
inherited

Retrieve destination directory value

Inherited from: \Zend_File_Transfer_Adapter_Abstract::getDestination()
Parameters
Name Type Description
$files null | string | array
Returns
Type Description
null | string | array
methodpublicgetErrors() : array
inherited

Retrieve error codes

Inherited from: \Zend_File_Transfer_Adapter_Abstract::getErrors()
Returns
Type Description
array
methodpublicgetFile() : array
inherited

Returns all set files

Inherited from: \Zend_File_Transfer_Adapter_Abstract::getFile()
Returns
Type Description
array List of set files
Throws
Exception Description
\Zend_File_Transfer_Exception Not implemented
methodpublicgetFileInfo(string $file = null) : array
inherited

Retrieve additional internal file informations for files

Inherited from: \Zend_File_Transfer_Adapter_Abstract::getFileInfo()
Parameters
Name Type Description
$file string

(Optional) File to get informations for

Returns
Type Description
array
methodpublicgetFileName( $file = null, boolean $path = true) : string | array
inherited

Retrieves the filename of transferred files.

Inherited from: \Zend_File_Transfer_Adapter_Abstract::getFileName()
Parameters
Name Type Description
$file
$path boolean

(Optional) Should the path also be returned ?

Returns
Type Description
string | array
methodpublicgetFileSize(string | array $files = null) : string | array
inherited

Returns the real filesize of the file

Inherited from: \Zend_File_Transfer_Adapter_Abstract::getFileSize()
Parameters
Name Type Description
$files string | array

Files to get the filesize from

Returns
Type Description
string | array Filesize
Throws
Exception Description
\Zend_File_Transfer_Exception When the file does not exist
methodpublicgetFilter(string $name) : \Zend_Filter_Interface | null
inherited

Retrieve individual filter

Inherited from: \Zend_File_Transfer_Adapter_Abstract::getFilter()
Parameters
Name Type Description
$name string
Returns
Type Description
\Zend_Filter_Interface | null
methodpublicgetFilters(string | array $files = null) : array
inherited

Returns all set filters

Inherited from: \Zend_File_Transfer_Adapter_Abstract::getFilters()
Parameters
Name Type Description
$files string | array

(Optional) Returns the filter for this files

Returns
Type Description
array List of set filters
Throws
Exception Description
\Zend_File_Transfer_Exception When file not found
methodpublicgetHash(string $hash = 'crc32', string | array $files = null) : string | array
inherited

Returns the hash for a given file

Inherited from: \Zend_File_Transfer_Adapter_Abstract::getHash()
Parameters
Name Type Description
$hash string

Hash algorithm to use

$files string | array

Files to return the hash for

Returns
Type Description
string | array Hashstring
Throws
Exception Description
\Zend_File_Transfer_Exception On unknown hash algorithm
methodpublicgetMessages() : array
inherited

Returns found validation messages

Inherited from: \Zend_File_Transfer_Adapter_Abstract::getMessages()
Returns
Type Description
array
methodpublicgetMimeType(string | array $files = null) : string | array
inherited

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()
Parameters
Name Type Description
$files string | array

Files to get the mimetype from

Returns
Type Description
string | array MimeType
Throws
Exception Description
\Zend_File_Transfer_Exception When the file does not exist
methodpublicgetOptions(array $files = null) : array
inherited

Returns set options for adapters or files

Inherited from: \Zend_File_Transfer_Adapter_Abstract::getOptions()
Parameters
Name Type Description
$files array

(Optional) Files to return the options for

Returns
Type Description
array Options for given files
methodpublicgetPluginLoader(string $type) : \Zend_Loader_PluginLoader
inherited

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.

Parameters
Name Type Description
$type string
Returns
Type Description
\Zend_Loader_PluginLoader
Throws
Exception Description
\Zend_File_Transfer_Exception on invalid type.
methodpublicgetProgress(string $id = null) : array | null
static

Returns the actual progress of file up-/downloads

Parameters
Name Type Description
$id string

The upload to get the progress for

Returns
Type Description
array | null
methodpublicgetTranslator() : \Zend_Translate_Adapter | null
inherited

Retrieve localization translator object

Inherited from: \Zend_File_Transfer_Adapter_Abstract::getTranslator()
Returns
Type Description
\Zend_Translate_Adapter | null
methodpublicgetType() : array
inherited

Returns all set types

Inherited from: \Zend_File_Transfer_Adapter_Abstract::getType()
Returns
Type Description
array List of set types
Throws
Exception Description
\Zend_File_Transfer_Exception Not implemented
methodpublicgetValidator(string $name) : \Zend_Validate_Interface | null
inherited

Retrieve individual validator

Inherited from: \Zend_File_Transfer_Adapter_Abstract::getValidator()
Parameters
Name Type Description
$name string
Returns
Type Description
\Zend_Validate_Interface | null
methodpublicgetValidators(string | array $files = null) : null | array
inherited

Returns all set validators

Inherited from: \Zend_File_Transfer_Adapter_Abstract::getValidators()
Parameters
Name Type Description
$files string | array

(Optional) Returns the validator for this files

Returns
Type Description
null | array List of set validators
methodpublichasErrors() : boolean
inherited

Are there errors registered?

Inherited from: \Zend_File_Transfer_Adapter_Abstract::hasErrors()
Returns
Type Description
boolean
methodpublichasFilter(string $name) : bool
inherited

Determine if a given filter has already been registered

Inherited from: \Zend_File_Transfer_Adapter_Abstract::hasFilter()
Parameters
Name Type Description
$name string
Returns
Type Description
bool
methodpublichasValidator(string $name) : bool
inherited

Determine if a given validator has already been registered

Inherited from: \Zend_File_Transfer_Adapter_Abstract::hasValidator()
Parameters
Name Type Description
$name string
Returns
Type Description
bool
methodpublicisApcAvailable() : boolean
static

Checks the APC extension for progress information

Returns
Type Description
boolean
methodpublicisFiltered(string | array $files = null) : bool

Checks if the file was already filtered

Parameters
Name Type Description
$files string | array

(Optional) Files to check

Returns
Type Description
bool
methodpublicisReceived(string | array $files = null) : bool

Checks if the file was already received

Parameters
Name Type Description
$files string | array

(Optional) Files to check

Returns
Type Description
bool
methodpublicisSent( $files = null) : bool

Checks if the file was already sent

Parameters
Name Type Description
$files
Returns
Type Description
bool
Throws
Exception Description
\Zend_File_Transfer_Exception Not implemented
methodpublicisUploadProgressAvailable() : boolean
static

Checks the UploadProgress extension for progress information

Returns
Type Description
boolean
methodpublicisUploaded( $files = null) : bool

Has a file been uploaded ?

Parameters
Name Type Description
$files
Returns
Type Description
bool
methodpublicisValid(string | array $files = null) : boolean

Checks if the files are valid

Parameters
Name Type Description
$files string | array

(Optional) Files to check

Returns
Type Description
boolean True if all checks are valid
methodpublicreceive(string | array $files = null) : bool

Receive the file from the client (Upload)

Parameters
Name Type Description
$files string | array

(Optional) Files to receive

Returns
Type Description
bool
methodpublicremoveFilter(string $name) : \Zend_File_Transfer_Adapter_Abstract
inherited

Remove an individual filter

Inherited from: \Zend_File_Transfer_Adapter_Abstract::removeFilter()
Parameters
Name Type Description
$name string
Returns
Type Description
\Zend_File_Transfer_Adapter_Abstract
methodpublicremoveValidator(string $name) : \Zend_File_Transfer_Adapter_Abstract

Remove an individual validator

Parameters
Name Type Description
$name string
Returns
Type Description
\Zend_File_Transfer_Adapter_Abstract
methodpublicsend(string | array $options = null) : void

Send the file to the client (Download)

Parameters
Name Type Description
$options string | array

Options for the file(s) to send

Throws
Exception Description
\Zend_File_Transfer_Exception Not implemented
methodpublicsetDestination(string $destination, string | array $files = null) : \Zend_File_Transfer_Abstract
inherited

Sets a new destination for the given files

Inherited from: \Zend_File_Transfer_Adapter_Abstract::setDestination()
Parameters
Name Type Description
$destination string

New destination directory

$files string | array

Files to set the new destination for

Returns
Type Description
\Zend_File_Transfer_Abstract
Throws
Exception Description
\Zend_File_Transfer_Exception when the given destination is not a directory or does not exist
methodpublicsetDisableTranslator(bool $flag) : \Zend_File_Transfer_Abstract
inherited

Indicate whether or not translation should be disabled

Inherited from: \Zend_File_Transfer_Adapter_Abstract::setDisableTranslator()
Parameters
Name Type Description
$flag bool
Returns
Type Description
\Zend_File_Transfer_Abstract
methodpublicsetFilters( $filters, string | array $files = null) : \Zend_File_Transfer_Adapter
inherited

Sets a filter for the class, erasing all previous set

Inherited from: \Zend_File_Transfer_Adapter_Abstract::setFilters()
Parameters
Name Type Description
$filters
$files string | array

Files to limit this filter to

Returns
Type Description
\Zend_File_Transfer_Adapter
methodpublicsetOptions(array $options = array(), array $files = null) : void
inherited

Sets Options for adapters

Inherited from: \Zend_File_Transfer_Adapter_Abstract::setOptions()
Parameters
Name Type Description
$options array

Options to set

$files array

(Optional) Files to set the options for

methodpublicsetPluginLoader(\Zend_Loader_PluginLoader_Interface $loader, string $type) : \Zend_File_Transfer_Adapter_Abstract
inherited

Set plugin loader to use for validator or filter chain

Inherited from: \Zend_File_Transfer_Adapter_Abstract::setPluginLoader()
Parameters
Name Type Description
$loader \Zend_Loader_PluginLoader_Interface
$type string

'filter', or 'validate'

Returns
Type Description
\Zend_File_Transfer_Adapter_Abstract
Throws
Exception Description
\Zend_File_Transfer_Exception on invalid type
methodpublicsetTranslator(\Zend_Translate | null $translator = null) : \Zend_File_Transfer_Abstract
inherited

Set translator object for localization

Inherited from: \Zend_File_Transfer_Adapter_Abstract::setTranslator()
Parameters
Name Type Description
$translator \Zend_Translate | null
Returns
Type Description
\Zend_File_Transfer_Abstract
methodpublicsetValidators( $validators, string | array $files = null) : \Zend_File_Transfer_Adapter

Sets a validator for the class, erasing all previous set

Parameters
Name Type Description
$validators
$files string | array

Files to limit this validator to

Returns
Type Description
\Zend_File_Transfer_Adapter
methodpublictranslatorIsDisabled() : bool
inherited

Is translation disabled?

Inherited from: \Zend_File_Transfer_Adapter_Abstract::translatorIsDisabled()
Returns
Type Description
bool
Documentation was generated by phpDocumentor 2.0.0a8.