PHP 클래스 FileUpload\FileUpload

파일 보기 프로젝트 열기: gargron/fileupload 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$callbacks array Callbacks to be run
$fileContainer FileUpload\File File Container instance
$filename_generator FileUpload\FileNameGenerator\FileNameGenerator Path resolver instance
$files array The array of uploaded files
$filesystem FileUpload\FileSystem\FileSystem File system instance
$logger Psr\Log\LoggerInterface Optional logger
$messages array Default messages
$pathresolver FileUpload\PathResolver\PathResolver Path resolver instance
$server array $_SERVER
$upload array $_FILES
$validators array Validators to be run

공개 메소드들

메소드 설명
__construct ( array $upload, array $server, FileUpload\FileNameGenerator\FileNameGenerator $generator = null ) Construct this mother
addCallback ( string $event, Closure $callback ) Register callback for an event
addValidator ( FileUpload\Validator\Validator $v ) Add another validator
getFileContainer ( ) : FileUpload\File
getFileNameGenerator ( ) : FileUpload\FileNameGenerator\FileNameGenerator
getFileSystem ( ) : FileUpload\FileSystem\FileSystem
getFiles ( ) : array Returns an array of all uploaded files
getLogger ( ) : Psr\Log\LoggerInterface
getMessage ( integer $code ) : string Get an error message
getPathResolver ( ) : FileUpload\PathResolver\PathResolver
processAll ( ) : array Process entire submitted request
setFileNameGenerator ( FileUpload\FileNameGenerator\FileNameGenerator $fng ) Set filename generator
setFileSystem ( FileUpload\FileSystem\FileSystem $fs ) Set file system
setLogger ( Psr\Log\LoggerInterface $logger ) Set logger, optionally
setMessages ( array $new_messages ) Merge (overwrite) default error messages
setPathResolver ( FileUpload\PathResolver\PathResolver $pr ) Set path resolver

보호된 메소드들

메소드 설명
fixIntegerOverflow ( integer $int ) : float Ensure correct value for big integers
getConfigBytes ( string $val ) : float Convert size format from PHP config into bytes
getContentLength ( ) : integer Content-length header
getContentRange ( ) : array Content-range header
getContentType ( ) : string Content-type header
getFilename ( string $name, string $type, integer $index, array $content_range, string $tmp_name ) : string Get filename for submitted filename
getFilesize ( string $path, boolean $clear_cache = false ) : float Get size of file
getNewHeaders ( array $files, array $content_range ) : array Generate headers for response
getSize ( ) : integer Request size
process ( string $tmp_name, string $name, integer $size, string $type, integer $error, integer $index, array $content_range = null ) : FileUpload\File Process single submitted file
processCallbacksFor ( string $eventName, FileUpload\File $file ) : void Process callbacks for a given event
trimFilename ( string $name, string $type, integer $index, array $content_range ) : string Remove harmful characters from filename
validate ( string $tmp_name, FileUpload\File $file, integer $error, integer $index ) : boolean Validate upload using some default rules, and custom validators added via addValidator. Default rules:

비공개 메소드들

메소드 설명
prepareMessages ( ) Converts $messages array into a hash with strings as keys This allows us to work with the keys and values as if it was a hash Which it really should be but, well, arrays in PHP, am I right?

메소드 상세

__construct() 공개 메소드

Construct this mother
public __construct ( array $upload, array $server, FileUpload\FileNameGenerator\FileNameGenerator $generator = null )
$upload array
$server array
$generator FileUpload\FileNameGenerator\FileNameGenerator

addCallback() 공개 메소드

Register callback for an event
public addCallback ( string $event, Closure $callback )
$event string
$callback Closure

addValidator() 공개 메소드

Add another validator
public addValidator ( FileUpload\Validator\Validator $v )
$v FileUpload\Validator\Validator

fixIntegerOverflow() 보호된 메소드

Ensure correct value for big integers
protected fixIntegerOverflow ( integer $int ) : float
$int integer
리턴 float

getConfigBytes() 보호된 메소드

Convert size format from PHP config into bytes
protected getConfigBytes ( string $val ) : float
$val string
리턴 float

getContentLength() 보호된 메소드

Content-length header
protected getContentLength ( ) : integer
리턴 integer

getContentRange() 보호된 메소드

Content-range header
protected getContentRange ( ) : array
리턴 array

getContentType() 보호된 메소드

Content-type header
protected getContentType ( ) : string
리턴 string

getFileContainer() 공개 메소드

public getFileContainer ( ) : FileUpload\File
리턴 FileUpload\File

getFileNameGenerator() 공개 메소드

public getFileNameGenerator ( ) : FileUpload\FileNameGenerator\FileNameGenerator
리턴 FileUpload\FileNameGenerator\FileNameGenerator

getFileSystem() 공개 메소드

public getFileSystem ( ) : FileUpload\FileSystem\FileSystem
리턴 FileUpload\FileSystem\FileSystem

getFilename() 보호된 메소드

Get filename for submitted filename
protected getFilename ( string $name, string $type, integer $index, array $content_range, string $tmp_name ) : string
$name string
$type string
$index integer
$content_range array
$tmp_name string
리턴 string

getFiles() 공개 메소드

Returns an array of all uploaded files
public getFiles ( ) : array
리턴 array

getFilesize() 보호된 메소드

Get size of file
protected getFilesize ( string $path, boolean $clear_cache = false ) : float
$path string
$clear_cache boolean
리턴 float

getLogger() 공개 메소드

public getLogger ( ) : Psr\Log\LoggerInterface
리턴 Psr\Log\LoggerInterface

getMessage() 공개 메소드

Get an error message
public getMessage ( integer $code ) : string
$code integer
리턴 string

getNewHeaders() 보호된 메소드

Generate headers for response
protected getNewHeaders ( array $files, array $content_range ) : array
$files array
$content_range array
리턴 array

getPathResolver() 공개 메소드

public getPathResolver ( ) : FileUpload\PathResolver\PathResolver
리턴 FileUpload\PathResolver\PathResolver

getSize() 보호된 메소드

Request size
protected getSize ( ) : integer
리턴 integer

process() 보호된 메소드

Process single submitted file
protected process ( string $tmp_name, string $name, integer $size, string $type, integer $error, integer $index, array $content_range = null ) : FileUpload\File
$tmp_name string
$name string
$size integer
$type string
$error integer
$index integer
$content_range array
리턴 FileUpload\File

processAll() 공개 메소드

Process entire submitted request
public processAll ( ) : array
리턴 array Files and response headers

processCallbacksFor() 보호된 메소드

Process callbacks for a given event
protected processCallbacksFor ( string $eventName, FileUpload\File $file ) : void
$eventName string
$file FileUpload\File
리턴 void

setFileNameGenerator() 공개 메소드

Set filename generator
public setFileNameGenerator ( FileUpload\FileNameGenerator\FileNameGenerator $fng )
$fng FileUpload\FileNameGenerator\FileNameGenerator

setFileSystem() 공개 메소드

Set file system
public setFileSystem ( FileUpload\FileSystem\FileSystem $fs )
$fs FileUpload\FileSystem\FileSystem

setLogger() 공개 메소드

Set logger, optionally
public setLogger ( Psr\Log\LoggerInterface $logger )
$logger Psr\Log\LoggerInterface

setMessages() 공개 메소드

Merge (overwrite) default error messages
public setMessages ( array $new_messages )
$new_messages array

setPathResolver() 공개 메소드

Set path resolver
public setPathResolver ( FileUpload\PathResolver\PathResolver $pr )
$pr FileUpload\PathResolver\PathResolver

trimFilename() 보호된 메소드

Remove harmful characters from filename
protected trimFilename ( string $name, string $type, integer $index, array $content_range ) : string
$name string
$type string
$index integer
$content_range array
리턴 string

validate() 보호된 메소드

- No PHP errors from $_FILES - File size permitted by PHP config
protected validate ( string $tmp_name, FileUpload\File $file, integer $error, integer $index ) : boolean
$tmp_name string
$file FileUpload\File
$error integer
$index integer
리턴 boolean

프로퍼티 상세

$callbacks 보호되어 있는 프로퍼티

Callbacks to be run
protected array $callbacks
리턴 array

$fileContainer 보호되어 있는 프로퍼티

File Container instance
protected File,FileUpload $fileContainer
리턴 FileUpload\File

$filename_generator 보호되어 있는 프로퍼티

Path resolver instance
protected FileNameGenerator,FileUpload\FileNameGenerator $filename_generator
리턴 FileUpload\FileNameGenerator\FileNameGenerator

$files 보호되어 있는 프로퍼티

The array of uploaded files
protected array $files
리턴 array

$filesystem 보호되어 있는 프로퍼티

File system instance
protected FileSystem,FileUpload\FileSystem $filesystem
리턴 FileUpload\FileSystem\FileSystem

$logger 보호되어 있는 프로퍼티

Optional logger
protected LoggerInterface,Psr\Log $logger
리턴 Psr\Log\LoggerInterface

$messages 보호되어 있는 프로퍼티

Default messages
protected array $messages
리턴 array

$pathresolver 보호되어 있는 프로퍼티

Path resolver instance
protected PathResolver,FileUpload\PathResolver $pathresolver
리턴 FileUpload\PathResolver\PathResolver

$server 보호되어 있는 프로퍼티

$_SERVER
protected array $server
리턴 array

$upload 보호되어 있는 프로퍼티

$_FILES
protected array $upload
리턴 array

$validators 보호되어 있는 프로퍼티

Validators to be run
protected array $validators
리턴 array