PHP Класс Gdn_Upload, vanilla

Наследование: extends Gdn_Pluggable
Показать файл Открыть проект Примеры использования класса

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

Свойство Тип Описание
$_AllowedFileExtensions array
$_MaxFileSize integer
$_UploadedFile string

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

Метод Описание
__construct ( ) Class constructor.
allowFileExtension ( $Extension ) Adds an extension (or array of extensions) to the array of allowed file extensions.
canUpload ( null $UploadPath = null ) : boolean
clear ( )
copyLocal ( string $Name ) : string Copy an upload locally so that it can be operated on.
delete ( string $Name ) : boolean Delete an uploaded file.
formatFileSize ( integer $Bytes, integer $Precision = 1 ) : string Format a number of bytes with the largest unit.
generateTargetName ( $TargetFolder, string $Extension = 'jpg', boolean $Chunk = false ) : string
getUploadedFileExtension ( ) : mixed
getUploadedFileName ( ) : mixed
isUpload ( $inputName ) : boolean Check to see whether the user has selected a file for uploading.
isUploadUri ( string $uri ) : boolean Determine if a URI matches the format of a valid type/domain upload.
parse ( string $Name ) : array | boolean Parse a virtual filename that had previously been saved to the database.
saveAs ( $Source, $Target, array $Options = [] ) : array | boolean
unformatFileSize ( string $Formatted ) : integer Take a string formatted filesize and return the number of bytes.
url ( $Name ) : mixed
urls ( string $Type = null ) : string Returns the url prefix for a given type.
validateUpload ( $InputName, $ThrowException = true ) Validates the uploaded file. Returns the temporary name of the uploaded file.

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

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

Class constructor.
public __construct ( )

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

Adds an extension (or array of extensions) to the array of allowed file extensions.
public allowFileExtension ( $Extension )

canUpload() публичный статический Метод

public static canUpload ( null $UploadPath = null ) : boolean
$UploadPath null
Результат boolean

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

public clear ( )

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

Copy an upload locally so that it can be operated on.
public copyLocal ( string $Name ) : string
$Name string Filename to be copied.
Результат string Local file path.

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

Delete an uploaded file.
public delete ( string $Name ) : boolean
$Name string The name of the upload as saved in the database.
Результат boolean

formatFileSize() публичный статический Метод

Format a number of bytes with the largest unit.
public static formatFileSize ( integer $Bytes, integer $Precision = 1 ) : string
$Bytes integer The number of bytes.
$Precision integer The number of decimal places in the formatted number.
Результат string the formatted filesize.

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

public generateTargetName ( $TargetFolder, string $Extension = 'jpg', boolean $Chunk = false ) : string
$TargetFolder
$Extension string
$Chunk boolean
Результат string

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

public getUploadedFileExtension ( ) : mixed
Результат mixed

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

public getUploadedFileName ( ) : mixed
Результат mixed

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

Check to see whether the user has selected a file for uploading.
public isUpload ( $inputName ) : boolean
$inputName The input name of the file.
Результат boolean Whether a file has been selected for the fiels.

isUploadUri() публичный статический Метод

Determine if a URI matches the format of a valid type/domain upload.
public static isUploadUri ( string $uri ) : boolean
$uri string The URI to test. This would be the value saved in the database (ex. GDN_User.Photo).
Результат boolean Returns **true** if {@link uri} looks like an uploaded file or **false** otherwise.

parse() публичный статический Метод

There are various formats supported for the name, mostly due to legacy concerns. - http(s)://domain/path.ext: A fully qualified url. - /path/from/uploads.ext: This is a locally uploaded file. - /path/to/uploads/path.ext: A full path starting from the uploads directory (deprecated). - ~type/path.ext: A specific type of upload provided by a plugin (deprecated). - type://domain/path.ext: A specific type of upload provied by a plugin with additional domain information.
public static parse ( string $Name ) : array | boolean
$Name string The virtual name of the file.
Результат array | boolean Returns an array of parsed information or false if the parse failed.

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

public saveAs ( $Source, $Target, array $Options = [] ) : array | boolean
$Source
$Target
$Options array
Результат array | boolean

unformatFileSize() публичный статический Метод

Take a string formatted filesize and return the number of bytes.
public static unformatFileSize ( string $Formatted ) : integer
$Formatted string The formatted filesize.
Результат integer The number of bytes in the string.

url() публичный статический Метод

public static url ( $Name ) : mixed
$Name
Результат mixed

urls() публичный статический Метод

If there is a plugin that wants to store uploads at a different location or in a different way then they register themselves by subscribing to the Gdn_Upload_GetUrls_Handler event. After that they will be available here.
public static urls ( string $Type = null ) : string
$Type string The type of upload to get the prefix for.
Результат string The url prefix.

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

Validates the uploaded file. Returns the temporary name of the uploaded file.
public validateUpload ( $InputName, $ThrowException = true )

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

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

protected array $_AllowedFileExtensions
Результат array

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

protected int $_MaxFileSize
Результат integer

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

protected string $_UploadedFile
Результат string