CI_Upload Class Reference

List of all members.

Public Member Functions

 CI_Upload ($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 ()
 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)
 _prep_filename ($filename)

Public Attributes

 $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_"


Member Function Documentation

CI_Upload::_prep_filename ( filename  ) 

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

private

Parameters:
string 
Returns:
string

CI_Upload::CI_Upload ( props = array()  ) 

Constructor

public

CI_Upload::clean_file_name ( filename  ) 

Clean the file name for security

public

Parameters:
string 
Returns:
string

CI_Upload::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.

public

Returns:
array

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

Display the error message

public

Parameters:
string 
string 
Returns:
string

CI_Upload::do_upload ( field = 'userfile'  ) 

Perform the file upload

public

Returns:
bool

CI_Upload::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.

public

Returns:
void

CI_Upload::get_extension ( filename  ) 

Extract the file extension

public

Parameters:
string 
Returns:
string

CI_Upload::initialize ( config = array()  ) 

Initialize preferences

public

Parameters:
array 
Returns:
void

CI_Upload::is_allowed_dimensions (  ) 

Verify that the image is within the allowed width/height

public

Returns:
bool

CI_Upload::is_allowed_filesize (  ) 

Verify that the file is within the allowed size

public

Returns:
bool

CI_Upload::is_allowed_filetype (  ) 

Verify that the filetype is allowed

public

Returns:
bool

CI_Upload::is_image (  ) 

Validate the image

public

Returns:
bool

CI_Upload::limit_filename_length ( filename,
length 
)

Limit the File Name Length

public

Parameters:
string 
Returns:
string

CI_Upload::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

public

Parameters:
string 
Returns:
string

CI_Upload::set_allowed_types ( types  ) 

Set Allowed File Types

public

Parameters:
string 
Returns:
void

CI_Upload::set_error ( msg  ) 

Set an error message

public

Parameters:
string 
Returns:
void

CI_Upload::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.

public

Parameters:
string 
string 
Returns:
string

CI_Upload::set_image_properties ( path = ''  ) 

Set Image Properties

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

public

Parameters:
string 
Returns:
void

CI_Upload::set_max_filename ( n  ) 

Set Maximum File Name Length

public

Parameters:
integer 
Returns:
void

CI_Upload::set_max_filesize ( n  ) 

Set Maximum File Size

public

Parameters:
integer 
Returns:
void

CI_Upload::set_max_height ( n  ) 

Set Maximum Image Height

public

Parameters:
integer 
Returns:
void

CI_Upload::set_max_width ( n  ) 

Set Maximum Image Width

public

Parameters:
integer 
Returns:
void

CI_Upload::set_upload_path ( path  ) 

Set Upload Path

public

Parameters:
string 
Returns:
void

CI_Upload::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.

public

Parameters:
bool 
Returns:
void

CI_Upload::validate_upload_path (  ) 

Validate Upload Path

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

public

Returns:
bool


Member Data Documentation

CI_Upload::$allowed_types = ""

CI_Upload::$encrypt_name = FALSE

CI_Upload::$error_msg = array()

CI_Upload::$file_ext = ""

CI_Upload::$file_name = ""

CI_Upload::$file_size = ""

CI_Upload::$file_temp = ""

CI_Upload::$file_type = ""

CI_Upload::$image_height = ''

CI_Upload::$image_size_str = ''

CI_Upload::$image_type = ''

CI_Upload::$image_width = ''

CI_Upload::$is_image = FALSE

CI_Upload::$max_filename = 0

CI_Upload::$max_height = 0

CI_Upload::$max_size = 0

CI_Upload::$max_width = 0

CI_Upload::$mimes = array()

CI_Upload::$orig_name = ""

CI_Upload::$overwrite = FALSE

CI_Upload::$remove_spaces = TRUE

CI_Upload::$temp_prefix = "temp_file_"

CI_Upload::$upload_path = ""

CI_Upload::$xss_clean = FALSE


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

Generated on Sun Nov 16 16:09:18 2008 for CodeIgniter by  doxygen 1.5.7.1