-
Notifications
You must be signed in to change notification settings - Fork 0
CI_Upload
File Uploading Class
- Class name: CI_Upload
- Namespace:
public integer $max_size
Maximum file size
- Visibility: public
public integer $max_width
Maximum image width
- Visibility: public
public integer $max_height
Maximum image height
- Visibility: public
public integer $min_width
Minimum image width
- Visibility: public
public integer $min_height
Minimum image height
- Visibility: public
public integer $max_filename
Maximum filename length
- Visibility: public
public integer $max_filename_increment = 100
Maximum duplicate filename increment ID
- Visibility: public
public string $allowed_types = ''
Allowed file types
- Visibility: public
public string $file_temp = ''
Temporary filename
- Visibility: public
public string $file_name = ''
Filename
- Visibility: public
public string $orig_name = ''
Original filename
- Visibility: public
public string $file_type = ''
File type
- Visibility: public
public integer $file_size = NULL
File size
- Visibility: public
public string $file_ext = ''
Filename extension
- Visibility: public
public string $file_ext_tolower = FALSE
Force filename extension to lowercase
- Visibility: public
public string $upload_path = ''
Upload path
- Visibility: public
public boolean $overwrite = FALSE
Overwrite flag
- Visibility: public
public boolean $encrypt_name = FALSE
Obfuscate filename flag
- Visibility: public
public boolean $is_image = FALSE
Is image flag
- Visibility: public
public integer $image_width = NULL
Image width
- Visibility: public
public integer $image_height = NULL
Image height
- Visibility: public
public string $image_type = ''
Image type
- Visibility: public
public string $image_size_str = ''
Image size string
- Visibility: public
public array $error_msg = array()
Error messages list
- Visibility: public
public boolean $remove_spaces = TRUE
Remove spaces flag
- Visibility: public
public boolean $detect_mime = TRUE
MIME detection flag
- Visibility: public
public boolean $xss_clean = FALSE
XSS filter flag
- Visibility: public
public boolean $mod_mime_fix = TRUE
Apache mod_mime fix flag
- Visibility: public
public string $temp_prefix = 'temp_file_'
Temporary filename prefix
- Visibility: public
public boolean $client_name = ''
Filename sent by the client
- Visibility: public
protected string $_file_name_override = ''
Filename override
- Visibility: protected
protected array $_mimes = array()
MIME types list
- Visibility: protected
protected object $_CI
CI Singleton
- Visibility: protected
void CI_Upload::__construct($config)
Constructor
- Visibility: public
- $config mixed
\CI_Upload CI_Upload::initialize(array $config, boolean $reset)
Initialize preferences
- Visibility: public
- $config array
- $reset boolean
boolean CI_Upload::do_upload(string $field)
Perform the file upload
- Visibility: public
- $field string
mixed CI_Upload::data(string $index)
Finalized Data Array
Returns an associative array containing all of the information related to the upload, allowing the developer easy access in one array.
- Visibility: public
- $index string
\CI_Upload CI_Upload::set_upload_path(string $path)
Set Upload Path
- Visibility: public
- $path string
string CI_Upload::set_filename(string $path, string $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.
- Visibility: public
- $path string
- $filename string
\CI_Upload CI_Upload::set_max_filesize(integer $n)
Set Maximum File Size
- Visibility: public
- $n integer
\CI_Upload CI_Upload::set_max_size(integer $n)
Set Maximum File Size
An internal alias to set_max_filesize() to help with configuration as initialize() will look for a set_<property_name>() method ...
- Visibility: protected
- $n integer
\CI_Upload CI_Upload::set_max_filename(integer $n)
Set Maximum File Name Length
- Visibility: public
- $n integer
\CI_Upload CI_Upload::set_max_width(integer $n)
Set Maximum Image Width
- Visibility: public
- $n integer
\CI_Upload CI_Upload::set_max_height(integer $n)
Set Maximum Image Height
- Visibility: public
- $n integer
\CI_Upload CI_Upload::set_min_width(integer $n)
Set minimum image width
- Visibility: public
- $n integer
\CI_Upload CI_Upload::set_min_height(integer $n)
Set minimum image height
- Visibility: public
- $n integer
\CI_Upload CI_Upload::set_allowed_types(mixed $types)
Set Allowed File Types
- Visibility: public
- $types mixed
\CI_Upload CI_Upload::set_image_properties(string $path)
Set Image Properties
Uses GD to determine the width/height/type of image
- Visibility: public
- $path string
\CI_Upload CI_Upload::set_xss_clean(boolean $flag)
Set XSS Clean
Enables the XSS flag so that the file that was uploaded will be run through the XSS filter.
- Visibility: public
- $flag boolean
boolean CI_Upload::is_image()
Validate the image
- Visibility: public
boolean CI_Upload::is_allowed_filetype(boolean $ignore_mime)
Verify that the filetype is allowed
- Visibility: public
- $ignore_mime boolean
boolean CI_Upload::is_allowed_filesize()
Verify that the file is within the allowed size
- Visibility: public
boolean CI_Upload::is_allowed_dimensions()
Verify that the image is within the allowed width/height
- Visibility: public
boolean CI_Upload::validate_upload_path()
Validate Upload Path
Verifies that it is a valid upload path with proper permissions.
- Visibility: public
string CI_Upload::get_extension(string $filename)
Extract the file extension
- Visibility: public
- $filename string
string CI_Upload::limit_filename_length(string $filename, integer $length)
Limit the File Name Length
- Visibility: public
- $filename string
- $length integer
string 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.
- Visibility: public
\CI_Upload CI_Upload::set_error(string $msg, $log_level)
Set an error message
- Visibility: public
- $msg string
- $log_level mixed
string CI_Upload::display_errors(string $open, string $close)
Display the error message
- Visibility: public
- $open string
- $close string
string CI_Upload::_prep_filename(string $filename)
Prep Filename
Prevents possible script execution from Apache's handling of files' multiple extensions.
- Visibility: protected
- $filename string
void CI_Upload::_file_mime_type(array $file)
File MIME type
Detects the (actual) MIME type of the uploaded file, if possible. The input array is expected to be $_FILES[$field]
- Visibility: protected
- $file array