Constants

UPLOAD_ERR_USER_SIZE

UPLOAD_ERR_USER_SIZE = 9

File is too big by the user-defined max size

UPLOAD_ERR_NOT_ALLOWED

UPLOAD_ERR_NOT_ALLOWED = 10

File is not allowed, per user-definition

UPLOAD_ERR_DIR_NOT_EXIST

UPLOAD_ERR_DIR_NOT_EXIST = 11

Upload directory does not exist

UPLOAD_ERR_DIR_NOT_WRITABLE

UPLOAD_ERR_DIR_NOT_WRITABLE = 12

Upload directory not writable

UPLOAD_ERR_FILE_NOT_SECURE

UPLOAD_ERR_FILE_NOT_SECURE = 13

File security error

UPLOAD_ERR_UNEXPECTED

UPLOAD_ERR_UNEXPECTED = 14

Unexpected error

Properties

$errorMessages

$errorMessages : array

Error messageed

Type

array

$uploadDir

$uploadDir : string

The upload directory path

Type

string

$uploadedFile

$uploadedFile : string

The final filename of the uploaded file

Type

string

$maxSize

$maxSize : integer

Allowed maximum file size

Type

integer

$allowedTypes

$allowedTypes : array

Allowed file types

Type

array

$disallowedTypes

$disallowedTypes : array

Disallowed file types

Type

array

$overwrite

$overwrite : boolean

Overwrite flag

Type

boolean

$error

$error : integer

Error flag

Type

integer

Methods

__construct()

__construct(string  $dir, integer  $maxSize, array  $disallowedTypes = null, array  $allowedTypes = null) 

Constructor

Instantiate a file upload object

Parameters

string $dir
integer $maxSize
array $disallowedTypes
array $allowedTypes

create()

create(string  $dir, integer  $maxSize, array  $disallowedTypes = null, array  $allowedTypes = null) : \Pop\Http\Server\Upload

Create an upload object

Parameters

string $dir
integer $maxSize
array $disallowedTypes
array $allowedTypes

Returns

\Pop\Http\Server\Upload

checkDuplicate()

checkDuplicate(string  $dir, string  $file) : string

Set default file upload settings

Parameters

string $dir
string $file

Returns

string

setDefaults()

setDefaults() : \Pop\Http\Server\Upload

Set default file upload settings

Returns

\Pop\Http\Server\Upload

setUploadDir()

setUploadDir(string  $dir) : \Pop\Http\Server\Upload

Set the upload directory

Parameters

string $dir

Returns

\Pop\Http\Server\Upload

setMaxSize()

setMaxSize(integer  $maxSize) : \Pop\Http\Server\Upload

Set the upload directory

Parameters

integer $maxSize

Returns

\Pop\Http\Server\Upload

setAllowedTypes()

setAllowedTypes(array  $allowedTypes) : \Pop\Http\Server\Upload

Set the allowed types

Parameters

array $allowedTypes

Returns

\Pop\Http\Server\Upload

setDisallowedTypes()

setDisallowedTypes(array  $disallowedTypes) : \Pop\Http\Server\Upload

Set the disallowed types

Parameters

array $disallowedTypes

Returns

\Pop\Http\Server\Upload

addAllowedType()

addAllowedType(string  $type) : \Pop\Http\Server\Upload

Add an allowed type

Parameters

string $type

Returns

\Pop\Http\Server\Upload

addDisallowedType()

addDisallowedType(string  $type) : \Pop\Http\Server\Upload

Add a disallowed type

Parameters

string $type

Returns

\Pop\Http\Server\Upload

removeAllowedType()

removeAllowedType(string  $type) : \Pop\Http\Server\Upload

Remove an allowed type

Parameters

string $type

Returns

\Pop\Http\Server\Upload

removeDisallowedType()

removeDisallowedType(string  $type) : \Pop\Http\Server\Upload

Remove a disallowed type

Parameters

string $type

Returns

\Pop\Http\Server\Upload

overwrite()

overwrite(boolean  $overwrite) : \Pop\Http\Server\Upload

Set the overwrite flag

Parameters

boolean $overwrite

Returns

\Pop\Http\Server\Upload

getUploadDir()

getUploadDir() : string

Get the upload directory

Returns

string

getUploadedFile()

getUploadedFile() : string

Get uploaded file

Returns

string

getUploadedFullPath()

getUploadedFullPath() : string

Get uploaded file full path

Returns

string

getMaxSize()

getMaxSize() : integer

Get the max size allowed

Returns

integer

getDisallowedTypes()

getDisallowedTypes() : array

Get the disallowed file types

Returns

array

getAllowedTypes()

getAllowedTypes() : array

Get the allowed file types

Returns

array

isAllowed()

isAllowed(string  $ext) : boolean

Determine if a file type is allowed

Parameters

string $ext

Returns

boolean

isNotAllowed()

isNotAllowed(string  $ext) : boolean

Determine if a file type is not allowed

Parameters

string $ext

Returns

boolean

isOverwrite()

isOverwrite() : boolean

Determine if the overwrite flag is set

Returns

boolean

isSuccess()

isSuccess() : boolean

Determine if the upload was a success

Returns

boolean

isError()

isError() : boolean

Determine if the upload was an error

Returns

boolean

getErrorCode()

getErrorCode() : integer

Get the upload error code

Returns

integer

getErrorMessage()

getErrorMessage() : string

Get the upload error message

Returns

string

checkFilename()

checkFilename(string  $file) : string

Check filename for duplicates, returning a new filename appended with _#

Parameters

string $file

Returns

string

test()

test(array  $file) : boolean

Test a file upload before moving it

Parameters

array $file

Returns

boolean

upload()

upload(array  $file, string  $to = null, boolean  $secure = true) : mixed

Upload file to the upload dir, returns the newly uploaded file

Parameters

array $file
string $to
boolean $secure

Returns

mixed