Abstract class for file transfers (Downloads and Uploads)

category Zend
package Zend_File_Transfer
copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
license New BSD License

 Methods

Adds one or more files

addFile(string|array $file, string|array $validator = null, string|array $filter = null) : \Zend_File_Transfer_Adapter_Abstract

Parameters

$file

stringarray

File to add

$validator

stringarray

Validators to use for this file, must be set before

$filter

stringarray

Filters to use for this file, must be set before

Exceptions

\Zend_File_Transfer_Exception Not implemented

Returns

\Zend_File_Transfer_Adapter_Abstract

Adds a new filter for this class

addFilter(string|array $filter, string|array $options = null, string|array $files = null) : \Zend_File_Transfer_Adapter

Parameters

$filter

stringarray

Type of filter to add

$options

stringarray

Options to set for the filter

$files

stringarray

Files to limit this filter to

Returns

\Zend_File_Transfer_Adapter

Add Multiple filters at once

addFilters(array $filters, string|array $files = null) : \Zend_File_Transfer_Adapter_Abstract

Parameters

$filters

array

$files

stringarray

Returns

\Zend_File_Transfer_Adapter_Abstract

Add prefix path for plugin loader

addPrefixPath(string $prefix, string $path, string $type = null) : \Zend_File_Transfer_Adapter_Abstract

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

$prefix

string

$path

string

$type

string

Exceptions

\Zend_File_Transfer_Exception for invalid type

Returns

\Zend_File_Transfer_Adapter_Abstract

Add many prefix paths at once

addPrefixPaths(array $spec) : \Zend_File_Transfer_Exception

Parameters

$spec

array

Returns

\Zend_File_Transfer_Exception

Adds one or more type of files

addType(string|array $type, string|array $validator = null, string|array $filter = null) : \Zend_File_Transfer_Adapter_Abstract

Parameters

$type

stringarray

Type of files to add

$validator

stringarray

Validators to use for this file, must be set before

$filter

stringarray

Filters to use for this file, must be set before

Exceptions

\Zend_File_Transfer_Exception Not implemented

Returns

\Zend_File_Transfer_Adapter_Abstract

Adds a new validator for this class

addValidator(string|array $validator, boolean $breakChainOnFailure = false, string|array $options = null, string|array $files = null) : \Zend_File_Transfer_Adapter

Parameters

$validator

stringarray

Type of validator to add

$breakChainOnFailure

boolean

If the validation chain should stop an failure

$options

stringarray

Options to set for the validator

$files

stringarray

Files to limit this validator to

Returns

\Zend_File_Transfer_Adapter

Add Multiple validators at once

addValidators(array $validators, string|array $files = null) : \Zend_File_Transfer_Adapter_Abstract

Parameters

$validators

array

$files

stringarray

Returns

\Zend_File_Transfer_Adapter_Abstract

Remove all filters

clearFilters() : \Zend_File_Transfer_Adapter_Abstract

Returns

\Zend_File_Transfer_Adapter_Abstract

Remove all validators

clearValidators() : \Zend_File_Transfer_Adapter_Abstract

Returns

\Zend_File_Transfer_Adapter_Abstract

Retrieve destination directory value

getDestination(null|string|array $files = null) : null | string | array

Parameters

$files

nullstringarray

Exceptions

\Zend_File_Transfer_Exception

Returns

nullstringarray

Retrieve error codes

getErrors() : array

Returns

array

Returns all set files

getFile() : array

Exceptions

\Zend_File_Transfer_Exception Not implemented

Returns

arrayList of set files

Retrieve additional internal file informations for files

getFileInfo(string $file = null) : array

Parameters

$file

string

(Optional) File to get informations for

Returns

array

Retrieves the filename of transferred files.

getFileName(string|null $file = null, boolean $path = true) : string | array

Parameters

$file

stringnull

$path

boolean

(Optional) Should the path also be returned ?

Returns

stringarray

Returns the real filesize of the file

getFileSize(string|array $files = null) : string | array

Parameters

$files

stringarray

Files to get the filesize from

Exceptions

\Zend_File_Transfer_Exception When the file does not exist

Returns

stringarrayFilesize

Retrieve individual filter

getFilter(string $name) : \Zend_Filter_Interface | null

Parameters

$name

string

Returns

\Zend_Filter_Interfacenull

Returns all set filters

getFilters(string|array $files = null) : array

Parameters

$files

stringarray

(Optional) Returns the filter for this files

Exceptions

\Zend_File_Transfer_Exception When file not found

Returns

arrayList of set filters

Returns the hash for a given file

getHash(string $hash = 'crc32', string|array $files = null) : string | array

Parameters

$hash

string

Hash algorithm to use

$files

stringarray

Files to return the hash for

Exceptions

\Zend_File_Transfer_Exception On unknown hash algorithm

Returns

stringarrayHashstring

Returns found validation messages

getMessages() : array

Returns

array

Returns the real mimetype of the file Uses fileinfo, when not available mime_magic and as last fallback a manual given mimetype

getMimeType(string|array $files = null) : string | array

Parameters

$files

stringarray

Files to get the mimetype from

Exceptions

\Zend_File_Transfer_Exception When the file does not exist

Returns

stringarrayMimeType

Returns set options for adapters or files

getOptions(array $files = null) : array

Parameters

$files

array

(Optional) Files to return the options for

Returns

arrayOptions for given files

Retrieve plugin loader for validator or filter chain

getPluginLoader(string $type) : \Zend_Loader_PluginLoader

Instantiates with default rules if none available for that type. Use 'filter' or 'validate' for $type.

Parameters

$type

string

Exceptions

\Zend_File_Transfer_Exception on invalid type.

Returns

\Zend_Loader_PluginLoader

Retrieve progress of transfer

getProgress() : float
Static

Returns

float

Retrieve localization translator object

getTranslator() : \Zend_Translate_Adapter | null

Returns

\Zend_Translate_Adapternull

Returns all set types

getType() : array

Exceptions

\Zend_File_Transfer_Exception Not implemented

Returns

arrayList of set types

Retrieve individual validator

getValidator(string $name) : \Zend_Validate_Interface | null

Parameters

$name

string

Returns

\Zend_Validate_Interfacenull

Returns all set validators

getValidators(string|array $files = null) : null | array

Parameters

$files

stringarray

(Optional) Returns the validator for this files

Returns

nullarrayList of set validators

Are there errors registered?

hasErrors() : boolean

Returns

boolean

Determine if a given filter has already been registered

hasFilter(string $name) : boolean

Parameters

$name

string

Returns

boolean

Determine if a given validator has already been registered

hasValidator(string $name) : boolean

Parameters

$name

string

Returns

boolean

Has the file been filtered ?

isFiltered(array|string|null $files = null) : boolean

Parameters

$files

arraystringnull

Returns

boolean

Is file received?

isReceived(array|string|null $files = null) : boolean

Parameters

$files

arraystringnull

Returns

boolean

Is file sent?

isSent(array|string|null $files = null) : boolean

Parameters

$files

arraystringnull

Returns

boolean

Has a file been uploaded ?

isUploaded(array|string|null $files = null) : boolean

Parameters

$files

arraystringnull

Returns

boolean

Checks if the files are valid

isValid(string|array $files = null) : boolean

Parameters

$files

stringarray

(Optional) Files to check

Returns

booleanTrue if all checks are valid

Receive file

receive(mixed $options = null) : boolean

Parameters

$options

mixed

Returns

boolean

Remove an individual filter

removeFilter(string $name) : \Zend_File_Transfer_Adapter_Abstract

Parameters

$name

string

Returns

\Zend_File_Transfer_Adapter_Abstract

Remove an individual validator

removeValidator(string $name) : \Zend_File_Transfer_Adapter_Abstract

Parameters

$name

string

Returns

\Zend_File_Transfer_Adapter_Abstract

Send file

send(mixed $options = null) : boolean

Parameters

$options

mixed

Returns

boolean

Sets a new destination for the given files

setDestination(string $destination, string|array $files = null) : \Zend_File_Transfer_Abstract
deprecated Will be changed to be a filter!!!

Parameters

$destination

string

New destination directory

$files

stringarray

Files to set the new destination for

Exceptions

\Zend_File_Transfer_Exception when the given destination is not a directory or does not exist

Returns

\Zend_File_Transfer_Abstract

Indicate whether or not translation should be disabled

setDisableTranslator(boolean $flag) : \Zend_File_Transfer_Abstract

Parameters

$flag

boolean

Returns

\Zend_File_Transfer_Abstract

Sets a filter for the class, erasing all previous set

setFilters(array $filters, string|array $files = null) : \Zend_File_Transfer_Adapter

Parameters

$filters

$files

stringarray

Files to limit this filter to

Returns

\Zend_File_Transfer_Adapter

Sets Options for adapters

setOptions(array $options = array(), array $files = null) : \Zend_File_Transfer_Adapter_Abstract

Parameters

$options

array

Options to set

$files

array

(Optional) Files to set the options for

Returns

\Zend_File_Transfer_Adapter_Abstract

Set plugin loader to use for validator or filter chain

setPluginLoader(\Zend_Loader_PluginLoader_Interface $loader, string $type) : \Zend_File_Transfer_Adapter_Abstract

Parameters

$loader

\Zend_Loader_PluginLoader_Interface

$type

string

'filter', or 'validate'

Exceptions

\Zend_File_Transfer_Exception on invalid type

Returns

\Zend_File_Transfer_Adapter_Abstract

Set translator object for localization

setTranslator(\Zend_Translate|null $translator = null) : \Zend_File_Transfer_Abstract

Parameters

$translator

\Zend_Translatenull

Exceptions

\Zend_File_Transfer_Exception

Returns

\Zend_File_Transfer_Abstract

Sets a validator for the class, erasing all previous set

setValidators(array $validators, string|array $files = null) : \Zend_File_Transfer_Adapter

Parameters

$validators

$files

stringarray

Files to limit this validator to

Returns

\Zend_File_Transfer_Adapter

Is translation disabled?

translatorIsDisabled() : boolean

Returns

boolean

Internal method to detect the size of a file

_detectFileSize(array $value) : string

Parameters

$value

array

File infos

Returns

stringFilesize of given file

Internal method to detect the mime type of a file

_detectMimeType(array $value) : string

Parameters

$value

array

File infos

Returns

stringMimetype of given file

Internal function to filter all given files

_filter(string|array $files = null) : boolean

Parameters

$files

stringarray

(Optional) Files to check

Returns

booleanFalse on error

Returns found files based on internal file array and given files

_getFiles(string|array $files, boolean $names = false, boolean $noexception = false) : array

Parameters

$files

stringarray

(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

Exceptions

\Zend_File_Transfer_Exception On false filename

Returns

arrayFound files

Retrieve internal identifier for a named filter

_getFilterIdentifier(string $name) : string

Parameters

$name

string

Returns

string

Determine system TMP directory and detect if we have read access

_getTmpDir() : string

Exceptions

\Zend_File_Transfer_Exception if unable to determine directory

Returns

string

Retrieve internal identifier for a named validator

_getValidatorIdentifier(string $name) : string

Parameters

$name

string

Returns

string

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

_isPathWriteable(string $path) : boolean

Parameters

$path

string

Returns

boolean

Returns the formatted size

_toByteString(integer $size) : string
Static

Parameters

$size

integer

Returns

string

 Properties

 

Internal list of breaks

$_break : array

Default

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 ))

$_files : array

Default

array()
 

Internal list of filters

$_filters : array

Default

array()
 

Plugin loaders for filter and validation chains

$_loaders : array

Default

array()
 

Internal list of messages

$_messages : array

Default

array()
 

Available options for file transfers

$_options 

Default

array('ignoreNoFile' => false, 'useByteString' => true, 'magicFile' => null, 'detectInfos' => true)
 

TMP directory

$_tmpDir : string

Default

 

$_translator

$_translator : \Zend_Translate

Default

 

Is translation disabled?

$_translatorDisabled : boolean

Default

false
 

Internal list of validators

$_validators : array

Default

array()

 Constants

 

FILTER

FILTER = 'FILTER' 
 

VALIDATE

VALIDATE = 'VALIDATE'