PHP Class uploader

S('class/uploader')->sendToSae() S('class/uploader')->sendToKupan() S('class/uploader')->sendToQiniu() S('class/uploader')->sendToTietu()
Author: suconghou
Datei anzeigen Open project: anchorcms/anchor-cms Class Usage Examples

Protected Properties

Property Type Description
$destination string The path where uploaded files will be moved to
$extensions array Holds array of valid file extensions

Public Methods

Method Description
__construct ( $destination, $extensions = [] ) Create a new instance of the uploader
set_destination ( $path ) Sets the upload destination path
set_extensions ( $extensions ) Sets the upload accepted extensions
upload ( $file, $filename = null ) : string Upload a file

Protected Methods

Method Description
format_filename ( $filename ) : string Strips none alphanumeric and dash characters
get_error_message ( $error ) : string Translates error codes to error messages
get_filename ( $filename ) : string Creates a friendly file name
validate ( $file ) Validates the passed $_FILES value and extension

Method Details

__construct() public method

Create a new instance of the uploader
public __construct ( $destination, $extensions = [] )

format_filename() protected method

Strips none alphanumeric and dash characters
protected format_filename ( $filename ) : string
return string

get_error_message() protected method

Translates error codes to error messages
protected get_error_message ( $error ) : string
return string

get_filename() protected method

Creates a friendly file name
protected get_filename ( $filename ) : string
return string

set_destination() public method

Sets the upload destination path
public set_destination ( $path )

set_extensions() public method

Sets the upload accepted extensions
public set_extensions ( $extensions )

upload() public method

Upload a file
public upload ( $file, $filename = null ) : string
return string

validate() protected method

Validates the passed $_FILES value and extension
protected validate ( $file )

Property Details

$destination protected_oe property

The path where uploaded files will be moved to
protected string $destination
return string

$extensions protected_oe property

Holds array of valid file extensions
protected array $extensions
return array