PHP 클래스 Sirius\Upload\Handler

상속: implements Sirius\Upload\UploadHandlerInterface
파일 보기 프로젝트 열기: siriusphp/upload 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$autoconfirm boolean Whether or not the uploaded files are auto confirmed
$container Sirius\Upload\Container\ContainerInterface
$overwrite boolean When uploading a file that has the same name as a file that is already in the container should it overwrite it or use another name
$prefix string | callback It can be a subfolder (if it ends with '/', a string to be used as prefix) or a callback that returns a string
$sanitizerCallback function | callback
$validator Sirius\Validation\ValueValidator

공개 메소드들

메소드 설명
__construct ( $directoryOrContainer, array $options = [], Sirius\Validation\ValueValidator $validator = null )
addRule ( string $name, mixed $options = null, string $errorMessageTemplate = null, string $label = null ) : Handler Add validation rule (extension|size|width|height|ratio)
process ( array $files = [] ) : Sirius\Upload\Result\Collection | Sirius\Upload\Result\File Processes a file upload and returns an upload result file/collection
setAutoconfirm ( boolean $autoconfirm ) : Handler Enable/disable upload autoconfirmation Autoconfirmation does not require calling confirm()
setOverwrite ( boolean $overwrite ) : Handler Enable/disable upload overwrite
setPrefix ( string | callable $prefix ) : Handler File prefix for the upload. Can be - a folder (if it ends with /) - a string to be used as prefix - a function that returns a string
setSanitizerCallback ( callable $callback ) : Handler Set the sanitizer function for cleaning up the file names

보호된 메소드들

메소드 설명
processSingleFile ( array $file ) : array Processes a single uploaded file - sanitize the name - validates the file - if valid, moves the file to the container
sanitizeFileName ( string $name ) : string Sanitize the name of the uploaded file by stripping away bad characters and replacing "invalid" characters with underscore _
validateFile ( $file ) : mixed Validates a file according to the rules configured on the handler

메소드 상세

__construct() 공개 메소드

public __construct ( $directoryOrContainer, array $options = [], Sirius\Validation\ValueValidator $validator = null )
$directoryOrContainer
$options array
$validator Sirius\Validation\ValueValidator

addRule() 공개 메소드

Add validation rule (extension|size|width|height|ratio)
public addRule ( string $name, mixed $options = null, string $errorMessageTemplate = null, string $label = null ) : Handler
$name string
$options mixed
$errorMessageTemplate string
$label string
리턴 Handler

process() 공개 메소드

Processes a file upload and returns an upload result file/collection
public process ( array $files = [] ) : Sirius\Upload\Result\Collection | Sirius\Upload\Result\File
$files array
리턴 Sirius\Upload\Result\Collection | Sirius\Upload\Result\File

processSingleFile() 보호된 메소드

Processes a single uploaded file - sanitize the name - validates the file - if valid, moves the file to the container
protected processSingleFile ( array $file ) : array
$file array
리턴 array

sanitizeFileName() 보호된 메소드

Sanitize the name of the uploaded file by stripping away bad characters and replacing "invalid" characters with underscore _
protected sanitizeFileName ( string $name ) : string
$name string
리턴 string

setAutoconfirm() 공개 메소드

Enable/disable upload autoconfirmation Autoconfirmation does not require calling confirm()
public setAutoconfirm ( boolean $autoconfirm ) : Handler
$autoconfirm boolean
리턴 Handler

setOverwrite() 공개 메소드

Enable/disable upload overwrite
public setOverwrite ( boolean $overwrite ) : Handler
$overwrite boolean
리턴 Handler

setPrefix() 공개 메소드

File prefix for the upload. Can be - a folder (if it ends with /) - a string to be used as prefix - a function that returns a string
public setPrefix ( string | callable $prefix ) : Handler
$prefix string | callable
리턴 Handler

setSanitizerCallback() 공개 메소드

Set the sanitizer function for cleaning up the file names
public setSanitizerCallback ( callable $callback ) : Handler
$callback callable
리턴 Handler

validateFile() 보호된 메소드

Validates a file according to the rules configured on the handler
protected validateFile ( $file ) : mixed
$file
리턴 mixed

프로퍼티 상세

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

Whether or not the uploaded files are auto confirmed
protected bool $autoconfirm
리턴 boolean

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

protected ContainerInterface,Sirius\Upload\Container $container
리턴 Sirius\Upload\Container\ContainerInterface

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

When uploading a file that has the same name as a file that is already in the container should it overwrite it or use another name
protected bool $overwrite
리턴 boolean

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

It can be a subfolder (if it ends with '/', a string to be used as prefix) or a callback that returns a string
protected string|callback $prefix
리턴 string | callback

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

protected function|callback $sanitizerCallback
리턴 function | callback

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

protected ValueValidator,Sirius\Validation $validator
리턴 Sirius\Validation\ValueValidator