My Project
 All Data Structures Namespaces Functions Variables
Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes
CI_Upload Class Reference

Public Member Functions

 __construct ($props=array())
 
 initialize ($config=array())
 
 do_upload ($field= 'userfile')
 
 data ()
 
 set_upload_path ($path)
 
 set_filename ($path, $filename)
 
 set_max_filesize ($n)
 
 set_max_filename ($n)
 
 set_max_width ($n)
 
 set_max_height ($n)
 
 set_allowed_types ($types)
 
 set_image_properties ($path= '')
 
 set_xss_clean ($flag=FALSE)
 
 is_image ()
 
 is_allowed_filetype ($ignore_mime=FALSE)
 
 is_allowed_filesize ()
 
 is_allowed_dimensions ()
 
 validate_upload_path ()
 
 get_extension ($filename)
 
 clean_file_name ($filename)
 
 limit_filename_length ($filename, $length)
 
 do_xss_clean ()
 
 set_error ($msg)
 
 display_errors ($open= '< p >', $close= '</p >')
 
 mimes_types ($mime)
 

Data Fields

 $max_size = 0
 
 $max_width = 0
 
 $max_height = 0
 
 $max_filename = 0
 
 $allowed_types = ""
 
 $file_temp = ""
 
 $file_name = ""
 
 $orig_name = ""
 
 $file_type = ""
 
 $file_size = ""
 
 $file_ext = ""
 
 $upload_path = ""
 
 $overwrite = FALSE
 
 $encrypt_name = FALSE
 
 $is_image = FALSE
 
 $image_width = ''
 
 $image_height = ''
 
 $image_type = ''
 
 $image_size_str = ''
 
 $error_msg = array()
 
 $mimes = array()
 
 $remove_spaces = TRUE
 
 $xss_clean = FALSE
 
 $temp_prefix = "temp_file_"
 
 $client_name = ''
 

Protected Member Functions

 _prep_filename ($filename)
 
 _file_mime_type ($file)
 

Protected Attributes

 $_file_name_override = ''
 

Constructor & Destructor Documentation

__construct (   $props = array())

Constructor

public

Member Function Documentation

_file_mime_type (   $file)
protected

File MIME type

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

Parameters
array
Returns
void
_prep_filename (   $filename)
protected

Prep Filename

Prevents possible script execution from Apache's handling of files multiple extensions http://httpd.apache.org/docs/1.3/mod/mod_mime.html#multipleext

Parameters
string
Returns
string
clean_file_name (   $filename)

Clean the file name for security

Parameters
string
Returns
string
data ( )

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
display_errors (   $open = '<p>',
  $close = '</p>' 
)

Display the error message

Parameters
string
string
Returns
string
do_upload (   $field = 'userfile')

Perform the file upload

Returns
bool
do_xss_clean ( )

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.

Returns
void
get_extension (   $filename)

Extract the file extension

Parameters
string
Returns
string
initialize (   $config = array())

Initialize preferences

Parameters
array
Returns
void
is_allowed_dimensions ( )

Verify that the image is within the allowed width/height

Returns
bool
is_allowed_filesize ( )

Verify that the file is within the allowed size

Returns
bool
is_allowed_filetype (   $ignore_mime = FALSE)

Verify that the filetype is allowed

Returns
bool
is_image ( )

Validate the image

Returns
bool
limit_filename_length (   $filename,
  $length 
)

Limit the File Name Length

Parameters
string
Returns
string
mimes_types (   $mime)

List of Mime Types

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

Parameters
string
Returns
string
set_allowed_types (   $types)

Set Allowed File Types

Parameters
string
Returns
void
set_error (   $msg)

Set an error message

Parameters
string
Returns
void
set_filename (   $path,
  $filename 
)

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
string
string
Returns
string
set_image_properties (   $path = '')

Set Image Properties

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

Parameters
string
Returns
void
set_max_filename (   $n)

Set Maximum File Name Length

Parameters
integer
Returns
void
set_max_filesize (   $n)

Set Maximum File Size

Parameters
integer
Returns
void
set_max_height (   $n)

Set Maximum Image Height

Parameters
integer
Returns
void
set_max_width (   $n)

Set Maximum Image Width

Parameters
integer
Returns
void
set_upload_path (   $path)

Set Upload Path

Parameters
string
Returns
void
set_xss_clean (   $flag = FALSE)

Set XSS Clean

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

Parameters
bool
Returns
void
validate_upload_path ( )

Validate Upload Path

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

Returns
bool

The documentation for this class was generated from the following file: