Properties

$max_size

$max_size : 

Type

$max_width

$max_width : 

Type

$max_height

$max_height : 

Type

$max_filename

$max_filename : 

Type

$allowed_types

$allowed_types : 

Type

$file_temp

$file_temp : 

Type

$file_name

$file_name : 

Type

$orig_name

$orig_name : 

Type

$file_type

$file_type : 

Type

$file_size

$file_size : 

Type

$file_ext

$file_ext : 

Type

$upload_path

$upload_path : 

Type

$overwrite

$overwrite : 

Type

$encrypt_name

$encrypt_name : 

Type

$is_image

$is_image : 

Type

$image_width

$image_width : 

Type

$image_height

$image_height : 

Type

$image_type

$image_type : 

Type

$image_size_str

$image_size_str : 

Type

$error_msg

$error_msg : 

Type

$mimes

$mimes : 

Type

$remove_spaces

$remove_spaces : 

Type

$xss_clean

$xss_clean : 

Type

$temp_prefix

$temp_prefix : 

Type

$client_name

$client_name : 

Type

$_file_name_override

$_file_name_override : 

Type

Methods

__construct()

__construct(  $props = array()) 

Constructor

Parameters

$props

initialize()

initialize(  $config = array()) : void

Initialize preferences

Parameters

$config

do_upload()

do_upload(  $field = 'userfile') : boolean

Perform the file upload

Parameters

$field

Returns

boolean

data()

data() : array

Finalized Data Array

Returns an associative array containing all of the information related to the upload, allowing the developer easy access in one array.

Returns

array

set_upload_path()

set_upload_path(  $path) : void

Set Upload Path

Parameters

$path

set_filename()

set_filename(  $path,   $filename) : string

Set the file name

This function takes a filename/path as input and looks for the existence of a file with the same name. If found, it will append a number to the end of the filename to avoid overwriting a pre-existing file.

Parameters

$path
$filename

Returns

string

set_max_filesize()

set_max_filesize(  $n) : void

Set Maximum File Size

Parameters

$n

set_max_filename()

set_max_filename(  $n) : void

Set Maximum File Name Length

Parameters

$n

set_max_width()

set_max_width(  $n) : void

Set Maximum Image Width

Parameters

$n

set_max_height()

set_max_height(  $n) : void

Set Maximum Image Height

Parameters

$n

set_allowed_types()

set_allowed_types(  $types) : void

Set Allowed File Types

Parameters

$types

set_image_properties()

set_image_properties(  $path = '') : void

Set Image Properties

Uses GD to determine the width/height/type of image

Parameters

$path

set_xss_clean()

set_xss_clean(  $flag = FALSE) : void

Set XSS Clean

Enables the XSS flag so that the file that was uploaded will be run through the XSS filter.

Parameters

$flag

is_image()

is_image() : boolean

Validate the image

Returns

boolean

is_allowed_filetype()

is_allowed_filetype(  $ignore_mime = FALSE) : boolean

Verify that the filetype is allowed

Parameters

$ignore_mime

Returns

boolean

is_allowed_filesize()

is_allowed_filesize() : boolean

Verify that the file is within the allowed size

Returns

boolean

is_allowed_dimensions()

is_allowed_dimensions() : boolean

Verify that the image is within the allowed width/height

Returns

boolean

validate_upload_path()

validate_upload_path() : boolean

Validate Upload Path

Verifies that it is a valid upload path with proper permissions.

Returns

boolean

get_extension()

get_extension(  $filename) : string

Extract the file extension

Parameters

$filename

Returns

string

clean_file_name()

clean_file_name(  $filename) : string

Clean the file name for security

Parameters

$filename

Returns

string

limit_filename_length()

limit_filename_length(  $filename,   $length) : string

Limit the File Name Length

Parameters

$filename
$length

Returns

string

do_xss_clean()

do_xss_clean() : void

Runs the file through the XSS clean function

This prevents people from embedding malicious code in their files. I'm not sure that it won't negatively affect certain files in unexpected ways, but so far I haven't found that it causes trouble.

set_error()

set_error(  $msg) : void

Set an error message

Parameters

$msg

display_errors()

display_errors(  $open = '<p>',   $close = '</p>') : string

Display the error message

Parameters

$open
$close

Returns

string

mimes_types()

mimes_types(  $mime) : string

List of Mime Types

This is a list of mime types. We use it to validate the "allowed types" set by the developer

Parameters

$mime

Returns

string

_file_mime_type()

_file_mime_type(  $file) : void

File MIME type

Detects the (actual) MIME type of the uploaded file, if possible. The input array is expected to be $_FILES[$field]

Parameters

$file