UploaderController
in package
Class UploaderController
Tags
Table of Contents
Constants
- PLUPLOAD_INPUT_ERR = 101
- PLUPLOAD_MOVE_ERR = 103
- PLUPLOAD_OUTPUT_ERR = 102
- PLUPLOAD_SECURITY_ERR = 105
- PLUPLOAD_TMPDIR_ERR = 100
- PLUPLOAD_TYPE_ERR = 104
- PLUPLOAD_UNKNOWN_ERR = 111
Properties
- $conf : array<string|int, mixed>
- Configuration array
- $_error : int
- Error id
- $_errors : array<string|int, mixed>
- List of errors
Methods
- getErrorCode() : int
- Retrieve or sanitize the error code
- getErrorMessage() : string
- Retrieve the error message
- handleRequest() : array<string|int, mixed>|bool
- Handles the upload request.
- noCacheHeaders() : mixed
- Send static no caching header
- sanitizeFileName() : string
- Sanitizes the filename by adding a .txt file extension to files with bad extensions and by removing strange characters.
- writeChunksToFile() : mixed
- Combine chunks from the specified folder into the single file.
- writeFileTo() : mixed
- Writes either a multipart/form-data message or a binary stream to the specified file.
- cleanup() : mixed
- Cleanup method
- rrmdir() : mixed
- Concise way to recursively remove a directory http://www.php.net/manual/en/function.rmdir.php#108113
Constants
PLUPLOAD_INPUT_ERR
public
mixed
PLUPLOAD_INPUT_ERR
= 101
PLUPLOAD_MOVE_ERR
public
mixed
PLUPLOAD_MOVE_ERR
= 103
PLUPLOAD_OUTPUT_ERR
public
mixed
PLUPLOAD_OUTPUT_ERR
= 102
PLUPLOAD_SECURITY_ERR
public
mixed
PLUPLOAD_SECURITY_ERR
= 105
PLUPLOAD_TMPDIR_ERR
public
mixed
PLUPLOAD_TMPDIR_ERR
= 100
PLUPLOAD_TYPE_ERR
public
mixed
PLUPLOAD_TYPE_ERR
= 104
PLUPLOAD_UNKNOWN_ERR
public
mixed
PLUPLOAD_UNKNOWN_ERR
= 111
Properties
$conf
Configuration array
public
static array<string|int, mixed>
$conf
$_error
Error id
protected
static int
$_error
= null
$_errors
List of errors
protected
static array<string|int, mixed>
$_errors
= array(self::PLUPLOAD_MOVE_ERR => 'Failed to move uploaded file.', self::PLUPLOAD_INPUT_ERR => 'Failed to open input stream.', self::PLUPLOAD_OUTPUT_ERR => 'Failed to open output stream.', self::PLUPLOAD_TMPDIR_ERR => 'Failed to open temp directory.', self::PLUPLOAD_TYPE_ERR => 'File type not allowed.', self::PLUPLOAD_UNKNOWN_ERR => 'Failed due to unknown error.', self::PLUPLOAD_SECURITY_ERR => 'File didn\'t pass security check.')
Methods
getErrorCode()
Retrieve or sanitize the error code
public
static getErrorCode([int $code = null ]) : int
Parameters
- $code : int = null
-
(optional) Code to check
Return values
int —Error code
getErrorMessage()
Retrieve the error message
public
static getErrorMessage([int $code = null ]) : string
Parameters
- $code : int = null
-
(optional) Code to get message for
Return values
string —Error message or empty string
handleRequest()
Handles the upload request.
public
static handleRequest([array<string|int, mixed> $conf = array() ]) : array<string|int, mixed>|bool
Parameters
- $conf : array<string|int, mixed> = array()
Return values
array<string|int, mixed>|boolnoCacheHeaders()
Send static no caching header
public
static noCacheHeaders() : mixed
sanitizeFileName()
Sanitizes the filename by adding a .txt file extension to files with bad extensions and by removing strange characters.
public
static sanitizeFileName(string $filename) : string
Parameters
- $filename : string
-
The filename to be sanitized
Return values
string —The sanitized filename
writeChunksToFile()
Combine chunks from the specified folder into the single file.
public
static writeChunksToFile(string $chunk_dir, string $file_path) : mixed
Parameters
- $chunk_dir : string
-
Temp directory with the chunks
- $file_path : string
-
The file to write the chunks to
Tags
writeFileTo()
Writes either a multipart/form-data message or a binary stream to the specified file.
public
static writeFileTo(string $file_path[, mixed $file_data_name = false ]) : mixed
Parameters
- $file_path : string
-
The path to write the file to
- $file_data_name : mixed = false
Tags
cleanup()
Cleanup method
protected
static cleanup() : mixed
rrmdir()
Concise way to recursively remove a directory http://www.php.net/manual/en/function.rmdir.php#108113
protected
static rrmdir(string $dir) : mixed
Parameters
- $dir : string
-
Directory to remove