Documentation

UploadedFile
in package
implements UploadedFileInterface

Interfaces, Classes and Traits

UploadedFileInterface
Value object representing a file uploaded through an HTTP request.

Table of Contents

$clientFilename  : string
$clientMediaType  : string
$error  : int
$errors  : array<string|int, int>
$file  : string|null
$moved  : bool
$size  : int
$stream  : StreamInterface|null
__construct()  : mixed
getClientFilename()  : string|null
Retrieve the filename sent by the client.
getClientMediaType()  : string|null
Retrieve the media type sent by the client.
getError()  : int
Retrieve the error associated with the uploaded file.
getSize()  : int|null
Retrieve the file size.
getStream()  : StreamInterface
Retrieve a stream representing the uploaded file.
isMoved()  : bool
moveTo()  : mixed
Move the uploaded file to a new location.
isOk()  : bool
Return true if there is no upload error
isStringNotEmpty()  : bool
isStringOrNull()  : bool
setClientFilename()  : mixed
setClientMediaType()  : mixed
setError()  : mixed
setSize()  : mixed
setStreamOrFile()  : mixed
Depending on the value set file or stream variable
validateActive()  : mixed

Properties

$errors

private static array<string|int, int> $errors = [UPLOAD_ERR_OK, UPLOAD_ERR_INI_SIZE, UPLOAD_ERR_FORM_SIZE, UPLOAD_ERR_PARTIAL, UPLOAD_ERR_NO_FILE, UPLOAD_ERR_NO_TMP_DIR, UPLOAD_ERR_CANT_WRITE, UPLOAD_ERR_EXTENSION]

Methods

__construct()

public __construct(StreamInterface|string|resource $streamOrFile, int $size, int $errorStatus[, string|null $clientFilename = null ][, string|null $clientMediaType = null ]) : mixed
Parameters
$streamOrFile : StreamInterface|string|resource
$size : int
$errorStatus : int
$clientFilename : string|null = null
$clientMediaType : string|null = null
Return values
mixed

getClientFilename()

Retrieve the filename sent by the client.

public getClientFilename() : string|null
Return values
string|null

The filename sent by the client or null if none was provided.

getClientMediaType()

Retrieve the media type sent by the client.

public getClientMediaType() : string|null
Return values
string|null

The media type sent by the client or null if none was provided.

getSize()

Retrieve the file size.

public getSize() : int|null
Return values
int|null

The file size in bytes or null if unknown.

getStream()

Retrieve a stream representing the uploaded file.

public getStream() : StreamInterface
Tags
throws
RuntimeException

if the upload was not successful.

Return values
StreamInterface

Stream representation of the uploaded file.

isMoved()

public isMoved() : bool
Return values
bool

moveTo()

Move the uploaded file to a new location.

public moveTo(string $targetPath) : mixed
Parameters
$targetPath : string

Path to which to move the uploaded file.

Tags
see
http://php.net/is_uploaded_file
see
http://php.net/move_uploaded_file
throws
RuntimeException

if the upload was not successful.

throws
InvalidArgumentException

if the $path specified is invalid.

throws
RuntimeException

on any error during the move operation, or on the second or subsequent call to the method.

Return values
mixed

isOk()

Return true if there is no upload error

private isOk() : bool
Return values
bool

isStringNotEmpty()

private isStringNotEmpty(mixed $param) : bool
Parameters
$param : mixed
Return values
bool

isStringOrNull()

private isStringOrNull(mixed $param) : bool
Parameters
$param : mixed
Return values
bool

setClientFilename()

private setClientFilename(string|null $clientFilename) : mixed
Parameters
$clientFilename : string|null
Tags
throws
InvalidArgumentException
Return values
mixed

setClientMediaType()

private setClientMediaType(string|null $clientMediaType) : mixed
Parameters
$clientMediaType : string|null
Tags
throws
InvalidArgumentException
Return values
mixed

setError()

private setError(int $error) : mixed
Parameters
$error : int
Tags
throws
InvalidArgumentException
Return values
mixed

setSize()

private setSize(int $size) : mixed
Parameters
$size : int
Tags
throws
InvalidArgumentException
Return values
mixed

setStreamOrFile()

Depending on the value set file or stream variable

private setStreamOrFile(mixed $streamOrFile) : mixed
Parameters
$streamOrFile : mixed
Tags
throws
InvalidArgumentException
Return values
mixed

validateActive()

private validateActive() : mixed
Tags
throws
RuntimeException

if is moved or not ok

Return values
mixed

Search results