Documentation

Upload
in package

This class merges the file Uploads coming from a client into the POST array, allowing beans and programmers to have easier access to the data coming from the client without trading in any security.

The class should not automatically store any data to avoid the user being able to inject uploads where unwanted. The class automatically names uploads when storing to avoid collissions, returning the name of the file it stored.

Tags
author

César de la Cal cesar@magic3w.com

since
0.1
last-revision

2013.07.01

Table of Contents

$meta  : array<string|int, mixed>
Contains the raw metadata that was initially sent with the _FILES array.
$stored  : string|null
$uploadDir  : string
Upload directory path (without trailing slash). This can be changed by invoking setUploadDirectory()
__construct()  : mixed
__get()  : mixed
attr()  : string
Returns an attribute from the upload, these attributes are usually name, type, tmp_name, size and error.
get()  : type
This method should be avoided in favor of attr() since the name get() seems very misleading here.
getData()  : mixed
getMaxUploadSize()  : Filesize
Returns the maximum uploadable file size
init()  : mixed
isOk()  : mixed
setUploadDirectory()  : mixed
store()  : FileInterface

Properties

$meta

Contains the raw metadata that was initially sent with the _FILES array.

private array<string|int, mixed> $meta

Since this is pretty deeply worked into the way PHP works we should leave it alone. Changes to the way this array is organized are rare and don't affect Spitfire based apps hardly.

Tags
see
http://php.net/manual/en/features.file-upload.post-method.php

For the array structure used

$stored

private string|null $stored

Contains filename if store() was called, null otherwise

$uploadDir

Upload directory path (without trailing slash). This can be changed by invoking setUploadDirectory()

private string $uploadDir

Methods

__construct()

public __construct(mixed $meta) : mixed
Parameters
$meta : mixed
Return values
mixed

__get()

public __get(mixed $name) : mixed
Parameters
$name : mixed
Return values
mixed

attr()

Returns an attribute from the upload, these attributes are usually name, type, tmp_name, size and error.

public attr(string $attribute) : string

Please note that this method accesses PHP's metadata directly and there

Parameters
$attribute : string
Tags
throws
PrivateException
Return values
string

get()

This method should be avoided in favor of attr() since the name get() seems very misleading here.

public get(type $attribute) : type
Parameters
$attribute : type
Tags
deprecated

since version 0.1-dev

Return values
type

getData()

public getData() : mixed
Return values
mixed

getMaxUploadSize()

Returns the maximum uploadable file size

public static getMaxUploadSize([array<string|int, Filesize$sizes = null ]) : Filesize
Parameters
$sizes : array<string|int, Filesize> = null

An array of Filesize instances, for use with tests

Return values
Filesize

init()

public static init() : mixed
Return values
mixed

isOk()

public isOk() : mixed
Return values
mixed

setUploadDirectory()

public setUploadDirectory(mixed $to) : mixed
Parameters
$to : mixed
Return values
mixed

Search results