File transfer adapter class for the HTTP protocol

This class needs a full rewrite. It re-implements functionality present in Zend\Filter\Input and/or Zend\Form\Element, and in a way that's inconsistent with either one. Additionally, plugin loader usage is now deprecated -- but modifying that should be done in tandem with a rewrite to utilize validator and filter chains instead.

 Methods

Constructor for Http File Transfers

__construct(array $options) 

Parameters

$options

array

OPTIONAL Options to set

Exceptions

\Zend\File\Transfer\Exception\PhpEnvironmentException if file uploads are not allowed

Adds a new filter for this class

addFilter(string | \Zend\Filter\FilterInterface $filter, string | array $options, string | array $files) : \Zend\File\Transfer\Adapter\AbstractAdapter
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::addFilter()

Parameters

$filter

string\Zend\Filter\FilterInterface

Type of filter to add

$options

stringarray

Options to set for the filter

$files

stringarray

Files to limit this filter to

Exceptions

\Zend\File\Transfer\Exception\InvalidArgumentException for invalid type

Returns

Add Multiple filters at once

addFilters(array $filters, string | array $files) : \Zend\File\Transfer\Adapter\AbstractAdapter
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::addFilters()

Parameters

$filters

array

$files

stringarray

Returns

Adds a new validator for this class

addValidator(string | \Zend\Validator\ValidatorInterface $validator, bool $breakChainOnFailure, string | array $options, string | array $files) : \Zend\File\Transfer\Adapter\AbstractAdapter
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::addValidator()

Parameters

$validator

string\Zend\Validator\ValidatorInterface

Type of validator to add

$breakChainOnFailure

bool

If the validation chain should stop an failure

$options

stringarray

Options to set for the validator

$files

stringarray

Files to limit this validator to

Exceptions

\Zend\File\Transfer\Exception\InvalidArgumentException for invalid type

Returns

Add Multiple validators at once

addValidators(array $validators, string | array $files) : \Zend\File\Transfer\Adapter\AbstractAdapter
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::addValidators()

Parameters

$validators

array

$files

stringarray

Exceptions

\Zend\File\Transfer\Exception\InvalidArgumentException for invalid type

Returns

Remove all filters

clearFilters() : \Zend\File\Transfer\Adapter\AbstractAdapter
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::clearFilters()

Returns

Retrieve destination directory value

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

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::getDestination()

Parameters

$files

nullstringarray

Exceptions

\Zend\File\Transfer\Exception\InvalidArgumentException

Returns

nullstringarray

Retrieve error codes

getErrors() : array
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::getErrors()

Returns

array

Retrieve additional internal file informations for files

getFileInfo(string $file) : array
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::getFileInfo()

Parameters

$file

string

(Optional) File to get informations for

Returns

array

Retrieves the filename of transferred files.

getFileName(string $file, bool $path) : string | array
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::getFileName()

Parameters

$file

string

(Optional) Element to return the filename for

$path

bool

(Optional) Should the path also be returned ?

Returns

stringarray

Returns the real filesize of the file

getFileSize(string | array $files) : string | array
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::getFileSize()

Parameters

$files

stringarray

Files to get the filesize from

Exceptions

\Zend\File\Transfer\Exception\InvalidArgumentException When the file does not exist

Returns

stringarrayFilesize

Retrieve individual filter

getFilter(string $name) : \Zend\Filter\FilterInterface | null
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::getFilter()

Parameters

$name

string

Returns

Get the filter plugin manager instance

getFilterManager() : \Zend\File\Transfer\Adapter\FilterPluginManager
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::getFilterManager()

Returns

Returns all set filters

getFilters(string | array $files) : array
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::getFilters()

Parameters

$files

stringarray

(Optional) Returns the filter for this files

Exceptions

\Zend\File\Transfer\Exception\RuntimeException When file not found

Returns

arrayList of set filters

Returns the hash for a given file

getHash(string $hash, string | array $files) : string | array
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::getHash()

Parameters

$hash

string

Hash algorithm to use

$files

stringarray

Files to return the hash for

Exceptions

\Zend\File\Transfer\Exception\InvalidArgumentException On unknown hash algorithm

Returns

stringarrayHashstring

Returns found validation messages

getMessages() : array
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::getMessages()

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) : string | array
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::getMimeType()

Parameters

$files

stringarray

Files to get the mimetype from

Exceptions

\Zend\File\Transfer\Exception\InvalidArgumentException When the file does not exist

Returns

stringarrayMimeType

Returns set options for adapters or files

getOptions(array $files) : array
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::getOptions()

Parameters

$files

array

(Optional) Files to return the options for

Returns

arrayOptions for given files

Returns the actual progress of file up-/downloads

getProgress(string | array $id) : array | null

Parameters

$id

stringarray

The upload to get the progress for

Exceptions

\Zend\File\Transfer\Exception\PhpEnvironmentException whether APC nor UploadProgress extension installed
\Zend\File\Transfer\Exception\RuntimeException

Returns

arraynull

Retrieve localization translator object

getTranslator() : \Zend\I18n\Translator\Translator | null
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::getTranslator()

Returns

Return the translation text domain

getTranslatorTextDomain() : string
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::getTranslatorTextDomain()

Returns

string

Retrieve individual validator

getValidator(string $name) : \Zend\Validator\ValidatorInterface | null
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::getValidator()

Parameters

$name

string

Returns

Get the validator plugin manager instance

getValidatorManager() : \Zend\File\Transfer\Adapter\ValidatorPluginManager
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::getValidatorManager()

Returns

Returns all set validators

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

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::getValidators()

Parameters

$files

stringarray

(Optional) Returns the validator for this files

Returns

nullarrayList of set validators

Are there errors registered?

hasErrors() : bool
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::hasErrors()

Returns

bool

Determine if a given filter has already been registered

hasFilter(string $name) : bool
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::hasFilter()

Parameters

$name

string

Returns

bool

Checks if the helper has a translator

hasTranslator() : bool
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::hasTranslator()

Returns

bool

Determine if a given validator has already been registered

hasValidator(string $name) : bool
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::hasValidator()

Parameters

$name

string

Returns

bool

Checks the APC extension for progress information

isApcAvailable() : bool

Returns

bool

Checks if the file was already filtered

isFiltered(string | array $files) : bool

Parameters

$files

stringarray

(Optional) Files to check

Returns

bool

Checks if the file was already received

isReceived(string | array $files) : bool

Parameters

$files

stringarray

(Optional) Files to check

Returns

bool

Checks if the file was already sent

isSent(string | array $files) : bool

Parameters

$files

stringarray

Files to check

Exceptions

\Zend\File\Transfer\Exception\BadMethodCallException Not implemented

Returns

bool

Is translation enabled?

isTranslatorEnabled() : bool
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::isTranslatorEnabled()

Returns

bool

Checks the UploadProgress extension for progress information

isUploadProgressAvailable() : bool

Returns

bool

Has a file been uploaded ?

isUploaded(array | string | null $files) : bool

Parameters

$files

arraystringnull

Returns

bool

Checks if the files are valid

isValid(string | array $files) : bool

Parameters

$files

stringarray

(Optional) Files to check

Returns

boolTrue if all checks are valid

Receive the file from the client (Upload)

receive(string | array $files) : bool

Parameters

$files

stringarray

(Optional) Files to receive

Returns

bool

Remove an individual filter

removeFilter(string $name) : \Zend\File\Transfer\Adapter\AbstractAdapter
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::removeFilter()

Parameters

$name

string

Returns

Remove an individual validator

removeValidator(string $name) : \Zend\File\Transfer\Adapter\AbstractAdapter

Parameters

$name

string

Returns

Send the file to the client (Download)

send(string | array $options) : void

Parameters

$options

stringarray

Options for the file(s) to send

Exceptions

\Zend\File\Transfer\Exception\BadMethodCallException Not implemented

Sets a new destination for the given files

setDestination(string $destination, string | array $files) : \Zend\File\Transfer\Adapter\AbstractAdapter
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::setDestination()

Parameters

$destination

string

New destination directory

$files

stringarray

Files to set the new destination for

Exceptions

\Zend\File\Transfer\Exception\InvalidArgumentException when the given destination is not a directory or does not exist

Returns

Set the filter plugin manager instance

setFilterManager(\Zend\File\Transfer\Adapter\FilterPluginManager $filterManager) : \Zend\File\Transfer\Adapter\AbstractAdapter
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::setFilterManager()

Parameters

Returns

Sets a filter for the class, erasing all previous set

setFilters(array $filters, string | array $files) : \Zend\Filter\AbstractFilter
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::setFilters()

Parameters

$filters

array

Filter to set

$files

stringarray

Files to limit this filter to

Returns

Sets Options for adapters

setOptions(array $options, array $files) : \Zend\File\Transfer\Adapter\AbstractAdapter
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::setOptions()

Parameters

$options

array

Options to set

$files

array

(Optional) Files to set the options for

Returns

Sets translator to use in helper

setTranslator(\Zend\I18n\Translator\Translator $translator, string $textDomain) : \Zend\File\Transfer\Adapter\AbstractAdapter
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::setTranslator()

Parameters

$translator

\Zend\I18n\Translator\Translator

[optional] translator. Default is null, which sets no translator.

$textDomain

string

[optional] text domain Default is null, which skips setTranslatorTextDomain

Returns

Indicate whether or not translation should be enabled

setTranslatorEnabled(bool $flag) : \Zend\File\Transfer\Adapter\AbstractAdapter
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::setTranslatorEnabled()

Parameters

$flag

bool

Returns

Set translation text domain

setTranslatorTextDomain(string $textDomain) : \Zend\File\Transfer\Adapter\AbstractAdapter
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::setTranslatorTextDomain()

Parameters

$textDomain

string

Returns

Set the validator plugin manager instance

setValidatorManager(\Zend\File\Transfer\Adapter\ValidatorPluginManager $validatorManager) : \Zend\File\Transfer\Adapter\AbstractAdapter
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::setValidatorManager()

Parameters

Returns

Sets a validator for the class, erasing all previous set

setValidators(array $validators, string | array $files) : \Zend\File\Transfer\Adapter\AbstractAdapter

Parameters

$validators

array

Validator to set

$files

stringarray

Files to limit this validator to

Returns

Internal method to detect the size of a file

detectFileSize(array $value) : string
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::detectFileSize()

Parameters

$value

array

File infos

Returns

stringFilesize of given file

Internal method to detect the mime type of a file

detectMimeType(array $value) : string
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::detectMimeType()

Parameters

$value

array

File infos

Returns

stringMimetype of given file

Internal function to filter all given files

filter(string | array $files) : bool
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::filter()

Parameters

$files

stringarray

(Optional) Files to check

Returns

boolFalse on error

Returns found files based on internal file array and given files

getFiles(string | array $files, bool $names, bool $noexception) : array
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::getFiles()

Parameters

$files

stringarray

(Optional) Files to return

$names

bool

(Optional) Returns only names on true, else complete info

$noexception

bool

(Optional) Allows throwing an exception, otherwise returns an empty array

Exceptions

\Zend\File\Transfer\Exception\RuntimeException On false filename

Returns

arrayFound files

Retrieve internal identifier for a named filter

getFilterIdentifier(string $name) : string
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::getFilterIdentifier()

Parameters

$name

string

Returns

string

Determine system TMP directory and detect if we have read access

getTmpDir() : string
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::getTmpDir()

Exceptions

\Zend\File\Transfer\Exception\RuntimeException if unable to determine directory

Returns

string

Retrieve internal identifier for a named validator

getValidatorIdentifier(string $name) : string
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::getValidatorIdentifier()

Parameters

$name

string

Returns

string

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

isPathWriteable(string $path) : bool
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::isPathWriteable()

Parameters

$path

string

Returns

bool

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

prepareFiles() : \Zend\File\Transfer\Adapter\Http

Returns the formatted size

toByteString(integer $size) : string
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::toByteString()

Parameters

$size

integer

Returns

string

 Properties

 

Internal list of breaks

$break : array
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::$$break
 

$callbackApc

$callbackApc 

 

$callbackUploadProgress

$callbackUploadProgress 

 

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, - Internally temporary filename for uploaded files error, - Error which has occurred destination, - New destination for this file validators, - Set validator names for this file files - Set file names for this file ))

$files : array
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::$$files
 

$filterManager

$filterManager : \Zend\File\Transfer\Adapter\FilterPluginManager
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::$$filterManager
 

Internal list of filters

$filters : array
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::$$filters
 

Plugin loaders for filter and validation chains

$loaders : array
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::$$loaders
 

Internal list of messages

$messages : array
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::$$messages
 

Available options for file transfers

$options 
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::$$options
 

TMP directory

$tmpDir : string
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::$$tmpDir
 

$translator

$translator : \Zend\I18n\Translator\Translator
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::$$translator
 

Is translation enabled?

$translatorEnabled : bool
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::$$translatorEnabled
 

Translator text domain (optional)

$translatorTextDomain : string
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::$$translatorTextDomain
 

$validatorManager

$validatorManager : \Zend\File\Transfer\Adapter\ValidatorPluginManager
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::$$validatorManager
 

Internal list of validators

$validators : array
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::$$validators

 Constants

 

FILTER

FILTER 
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::FILTER
 

VALIDATOR

VALIDATOR 
Inherited

inherited_from \Zend\File\Transfer\Adapter\AbstractAdapter::VALIDATOR