Constants

UPLOAD_ERR_USER_SIZE

UPLOAD_ERR_USER_SIZE

File is too big by the user-defined max size

UPLOAD_ERR_NOT_ALLOWED

UPLOAD_ERR_NOT_ALLOWED

File is not allowed, per user-definition

UPLOAD_ERR_DIR_NOT_EXIST

UPLOAD_ERR_DIR_NOT_EXIST

Upload directory does not exist

UPLOAD_ERR_DIR_NOT_WRITABLE

UPLOAD_ERR_DIR_NOT_WRITABLE

Upload directory not writable

UPLOAD_ERR_UNEXPECTED

UPLOAD_ERR_UNEXPECTED

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

make()

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

Make an upload object

Parameters

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

Returns

\Pop\Http\Upload

checkDuplicate()

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

Set default file upload settings

Parameters

string $dir
string $file

Returns

string

setDefaults()

setDefaults() : \Pop\Http\Upload

Set default file upload settings

Returns

\Pop\Http\Upload

setUploadDir()

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

Set the upload directory

Parameters

string $dir

Returns

\Pop\Http\Upload

setMaxSize()

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

Set the upload directory

Parameters

integer $maxSize

Returns

\Pop\Http\Upload

setAllowedTypes()

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

Set the allowed types

Parameters

array $allowedTypes

Returns

\Pop\Http\Upload

setDisallowedTypes()

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

Set the disallowed types

Parameters

array $disallowedTypes

Returns

\Pop\Http\Upload

addAllowedType()

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

Add an allowed type

Parameters

string $type

Returns

\Pop\Http\Upload

addDisallowedType()

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

Add a disallowed type

Parameters

string $type

Returns

\Pop\Http\Upload

removeAllowedType()

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

Remove an allowed type

Parameters

string $type

Returns

\Pop\Http\Upload

removeDisallowedType()

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

Remove a disallowed type

Parameters

string $type

Returns

\Pop\Http\Upload

overwrite()

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

Set the overwrite flag

Parameters

boolean $overwrite

Returns

\Pop\Http\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) : mixed

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

Parameters

array $file
string $to

Returns

mixed