PHP Class uploader

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

Protected Properties

Свойство Type Description
$destination string The path where uploaded files will be moved to
$extensions array Holds array of valid file extensions

Méthodes publiques

Méthode 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

Méthodes protégées

Méthode 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 méthode

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

format_filename() protected méthode

Strips none alphanumeric and dash characters
protected format_filename ( $filename ) : string
Résultat string

get_error_message() protected méthode

Translates error codes to error messages
protected get_error_message ( $error ) : string
Résultat string

get_filename() protected méthode

Creates a friendly file name
protected get_filename ( $filename ) : string
Résultat string

set_destination() public méthode

Sets the upload destination path
public set_destination ( $path )

set_extensions() public méthode

Sets the upload accepted extensions
public set_extensions ( $extensions )

upload() public méthode

Upload a file
public upload ( $file, $filename = null ) : string
Résultat string

validate() protected méthode

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
Résultat string

$extensions protected_oe property

Holds array of valid file extensions
protected array $extensions
Résultat array