PHP Класс CI_Upload, TastyIgniter

Автор: ExpressionEngine Dev Team
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$allowed_types string Allowed file types
$client_name boolean Filename sent by the client
$detect_mime boolean MIME detection flag
$encrypt_name boolean Obfuscate filename flag
$error_msg array Error messages list
$file_ext string Filename extension
$file_ext_tolower string Force filename extension to lowercase
$file_name string Filename
$file_size integer File size
$file_temp string Temporary filename
$file_type string File type
$image_height integer Image height
$image_size_str string Image size string
$image_type string Image type
$image_width integer Image width
$is_image boolean Is image flag
$max_filename integer Maximum filename length
$max_filename_increment integer Maximum duplicate filename increment ID
$max_height integer Maximum image height
$max_size integer Maximum file size
$max_width integer Maximum image width
$min_height integer Minimum image height
$min_width integer Minimum image width
$mod_mime_fix boolean Apache mod_mime fix flag
$orig_name string Original filename
$overwrite boolean Overwrite flag
$remove_spaces boolean Remove spaces flag
$temp_prefix string Temporary filename prefix
$upload_path string Upload path
$xss_clean boolean XSS filter flag

Защищенные свойства (Protected)

Свойство Тип Описание
$_CI object CI Singleton
$_file_name_override string Filename override
$_mimes array MIME types list

Открытые методы

Метод Описание
__construct ( $config = [] ) : void Constructor
data ( string $index = NULL ) : mixed Finalized Data Array
display_errors ( string $open = '<p>', string $close = '</p>' ) : string Display the error message
do_upload ( string $field = 'userfile' ) : boolean Perform the file upload
do_xss_clean ( ) : string Runs the file through the XSS clean function
get_extension ( string $filename ) : string Extract the file extension
initialize ( array $config = [], boolean $reset = TRUE ) : CI_Upload Initialize preferences
is_allowed_dimensions ( ) : boolean Verify that the image is within the allowed width/height
is_allowed_filesize ( ) : boolean Verify that the file is within the allowed size
is_allowed_filetype ( boolean $ignore_mime = FALSE ) : boolean Verify that the filetype is allowed
is_image ( ) : boolean Validate the image
limit_filename_length ( string $filename, integer $length ) : string Limit the File Name Length
set_allowed_types ( mixed $types ) : CI_Upload Set Allowed File Types
set_error ( string $msg, $log_level = 'error' ) : CI_Upload Set an error message
set_filename ( string $path, string $filename ) : string Set the file name
set_image_properties ( string $path = '' ) : CI_Upload Set Image Properties
set_max_filename ( integer $n ) : CI_Upload Set Maximum File Name Length
set_max_filesize ( integer $n ) : CI_Upload Set Maximum File Size
set_max_height ( integer $n ) : CI_Upload Set Maximum Image Height
set_max_width ( integer $n ) : CI_Upload Set Maximum Image Width
set_min_height ( integer $n ) : CI_Upload Set minimum image height
set_min_width ( integer $n ) : CI_Upload Set minimum image width
set_upload_path ( string $path ) : CI_Upload Set Upload Path
set_xss_clean ( boolean $flag = FALSE ) : CI_Upload Set XSS Clean
validate_upload_path ( ) : boolean Validate Upload Path

Защищенные методы

Метод Описание
_file_mime_type ( array $file ) : void File MIME type
_prep_filename ( string $filename ) : string Prep Filename
set_max_size ( integer $n ) : CI_Upload Set Maximum File Size

Описание методов

__construct() публичный Метод

Constructor
public __construct ( $config = [] ) : void
Результат void

_file_mime_type() защищенный Метод

Detects the (actual) MIME type of the uploaded file, if possible. The input array is expected to be $_FILES[$field]
protected _file_mime_type ( array $file ) : void
$file array
Результат void

_prep_filename() защищенный Метод

Prevents possible script execution from Apache's handling of files' multiple extensions.
protected _prep_filename ( string $filename ) : string
$filename string
Результат string

data() публичный Метод

Returns an associative array containing all of the information related to the upload, allowing the developer easy access in one array.
public data ( string $index = NULL ) : mixed
$index string
Результат mixed

display_errors() публичный Метод

Display the error message
public display_errors ( string $open = '<p>', string $close = '</p>' ) : string
$open string
$close string
Результат string

do_upload() публичный Метод

Perform the file upload
public do_upload ( string $field = 'userfile' ) : boolean
$field string
Результат boolean

do_xss_clean() публичный Метод

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 do_xss_clean ( ) : string
Результат string

get_extension() публичный Метод

Extract the file extension
public get_extension ( string $filename ) : string
$filename string
Результат string

initialize() публичный Метод

Initialize preferences
public initialize ( array $config = [], boolean $reset = TRUE ) : CI_Upload
$config array
$reset boolean
Результат CI_Upload

is_allowed_dimensions() публичный Метод

Verify that the image is within the allowed width/height
public is_allowed_dimensions ( ) : boolean
Результат boolean

is_allowed_filesize() публичный Метод

Verify that the file is within the allowed size
public is_allowed_filesize ( ) : boolean
Результат boolean

is_allowed_filetype() публичный Метод

Verify that the filetype is allowed
public is_allowed_filetype ( boolean $ignore_mime = FALSE ) : boolean
$ignore_mime boolean
Результат boolean

is_image() публичный Метод

Validate the image
public is_image ( ) : boolean
Результат boolean

limit_filename_length() публичный Метод

Limit the File Name Length
public limit_filename_length ( string $filename, integer $length ) : string
$filename string
$length integer
Результат string

set_allowed_types() публичный Метод

Set Allowed File Types
public set_allowed_types ( mixed $types ) : CI_Upload
$types mixed
Результат CI_Upload

set_error() публичный Метод

Set an error message
public set_error ( string $msg, $log_level = 'error' ) : CI_Upload
$msg string
Результат CI_Upload

set_filename() публичный Метод

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 set_filename ( string $path, string $filename ) : string
$path string
$filename string
Результат string

set_image_properties() публичный Метод

Uses GD to determine the width/height/type of image
public set_image_properties ( string $path = '' ) : CI_Upload
$path string
Результат CI_Upload

set_max_filename() публичный Метод

Set Maximum File Name Length
public set_max_filename ( integer $n ) : CI_Upload
$n integer
Результат CI_Upload

set_max_filesize() публичный Метод

Set Maximum File Size
public set_max_filesize ( integer $n ) : CI_Upload
$n integer
Результат CI_Upload

set_max_height() публичный Метод

Set Maximum Image Height
public set_max_height ( integer $n ) : CI_Upload
$n integer
Результат CI_Upload

set_max_size() защищенный Метод

An internal alias to set_max_filesize() to help with configuration as initialize() will look for a set_() method ...
protected set_max_size ( integer $n ) : CI_Upload
$n integer
Результат CI_Upload

set_max_width() публичный Метод

Set Maximum Image Width
public set_max_width ( integer $n ) : CI_Upload
$n integer
Результат CI_Upload

set_min_height() публичный Метод

Set minimum image height
public set_min_height ( integer $n ) : CI_Upload
$n integer
Результат CI_Upload

set_min_width() публичный Метод

Set minimum image width
public set_min_width ( integer $n ) : CI_Upload
$n integer
Результат CI_Upload

set_upload_path() публичный Метод

Set Upload Path
public set_upload_path ( string $path ) : CI_Upload
$path string
Результат CI_Upload

set_xss_clean() публичный Метод

Enables the XSS flag so that the file that was uploaded will be run through the XSS filter.
public set_xss_clean ( boolean $flag = FALSE ) : CI_Upload
$flag boolean
Результат CI_Upload

validate_upload_path() публичный Метод

Verifies that it is a valid upload path with proper permissions.
public validate_upload_path ( ) : boolean
Результат boolean

Описание свойств

$_CI защищенное свойство

CI Singleton
protected object $_CI
Результат object

$_file_name_override защищенное свойство

Filename override
protected string $_file_name_override
Результат string

$_mimes защищенное свойство

MIME types list
protected array $_mimes
Результат array

$allowed_types публичное свойство

Allowed file types
public string $allowed_types
Результат string

$client_name публичное свойство

Filename sent by the client
public bool $client_name
Результат boolean

$detect_mime публичное свойство

MIME detection flag
public bool $detect_mime
Результат boolean

$encrypt_name публичное свойство

Obfuscate filename flag
public bool $encrypt_name
Результат boolean

$error_msg публичное свойство

Error messages list
public array $error_msg
Результат array

$file_ext публичное свойство

Filename extension
public string $file_ext
Результат string

$file_ext_tolower публичное свойство

Force filename extension to lowercase
public string $file_ext_tolower
Результат string

$file_name публичное свойство

Filename
public string $file_name
Результат string

$file_size публичное свойство

File size
public int $file_size
Результат integer

$file_temp публичное свойство

Temporary filename
public string $file_temp
Результат string

$file_type публичное свойство

File type
public string $file_type
Результат string

$image_height публичное свойство

Image height
public int $image_height
Результат integer

$image_size_str публичное свойство

Image size string
public string $image_size_str
Результат string

$image_type публичное свойство

Image type
public string $image_type
Результат string

$image_width публичное свойство

Image width
public int $image_width
Результат integer

$is_image публичное свойство

Is image flag
public bool $is_image
Результат boolean

$max_filename публичное свойство

Maximum filename length
public int $max_filename
Результат integer

$max_filename_increment публичное свойство

Maximum duplicate filename increment ID
public int $max_filename_increment
Результат integer

$max_height публичное свойство

Maximum image height
public int $max_height
Результат integer

$max_size публичное свойство

Maximum file size
public int $max_size
Результат integer

$max_width публичное свойство

Maximum image width
public int $max_width
Результат integer

$min_height публичное свойство

Minimum image height
public int $min_height
Результат integer

$min_width публичное свойство

Minimum image width
public int $min_width
Результат integer

$mod_mime_fix публичное свойство

Apache mod_mime fix flag
public bool $mod_mime_fix
Результат boolean

$orig_name публичное свойство

Original filename
public string $orig_name
Результат string

$overwrite публичное свойство

Overwrite flag
public bool $overwrite
Результат boolean

$remove_spaces публичное свойство

Remove spaces flag
public bool $remove_spaces
Результат boolean

$temp_prefix публичное свойство

Temporary filename prefix
public string $temp_prefix
Результат string

$upload_path публичное свойство

Upload path
public string $upload_path
Результат string

$xss_clean публичное свойство

XSS filter flag
public bool $xss_clean
Результат boolean