UploadedFile
in package
implements
UploadedFileInterface
HTTP server uploaded file class
Tags
Table of Contents
Interfaces
- UploadedFileInterface
Properties
- $clientFilename : string|null
- Client-reported original filename
- $clientMediaType : string|null
- Client-reported media type
- $error : int
- One of PHP's UPLOAD_ERR_* constants
- $file : string
- Path to the underlying (typically temporary) uploaded file
- $moved : bool
- Whether moveTo() has already been called
- $size : int
- File size in bytes
- $stream : Body|null
- Lazily-built stream wrapping $file
Methods
- __construct() : mixed
- Constructor
- createFromFilesArray() : array<string|int, mixed>
- Normalize a native $_FILES-shaped array (flat or per-field multi-file) into an array of UploadedFile instances, preserving the original field-name keys
- fromFile() : UploadedFile
- Build a single UploadedFile instance from one $_FILES-shaped entry
- getClientFilename() : string|null
- Get the client-reported original filename
- getClientMediaType() : string|null
- Get the client-reported media type
- getError() : int
- Get the upload error code (one of PHP's UPLOAD_ERR_* constants)
- getSize() : int|null
- Get the file size in bytes
- getStream() : StreamInterface
- Get a stream wrapping the uploaded file's contents
- moveTo() : void
- Move the uploaded file to a new location
Properties
$clientFilename
Client-reported original filename
protected
string|null
$clientFilename
$clientMediaType
Client-reported media type
protected
string|null
$clientMediaType
$error
One of PHP's UPLOAD_ERR_* constants
protected
int
$error
$file
Path to the underlying (typically temporary) uploaded file
protected
string
$file
$moved
Whether moveTo() has already been called
protected
bool
$moved
= false
$size
File size in bytes
protected
int
$size
$stream
Lazily-built stream wrapping $file
protected
Body|null
$stream
= null
Methods
__construct()
Constructor
public
__construct(string $file, int $size, int $error[, string|null $clientFilename = null ][, string|null $clientMediaType = null ]) : mixed
Parameters
- $file : string
- $size : int
- $error : int
- $clientFilename : string|null = null
- $clientMediaType : string|null = null
createFromFilesArray()
Normalize a native $_FILES-shaped array (flat or per-field multi-file) into an array of UploadedFile instances, preserving the original field-name keys
public
static createFromFilesArray(array<string|int, mixed> $files) : array<string|int, mixed>
Parameters
- $files : array<string|int, mixed>
Return values
array<string|int, mixed>fromFile()
Build a single UploadedFile instance from one $_FILES-shaped entry
public
static fromFile(array<string|int, mixed> $file) : UploadedFile
Parameters
- $file : array<string|int, mixed>
Return values
UploadedFilegetClientFilename()
Get the client-reported original filename
public
getClientFilename() : string|null
Return values
string|nullgetClientMediaType()
Get the client-reported media type
public
getClientMediaType() : string|null
Return values
string|nullgetError()
Get the upload error code (one of PHP's UPLOAD_ERR_* constants)
public
getError() : int
Return values
intgetSize()
Get the file size in bytes
public
getSize() : int|null
Return values
int|nullgetStream()
Get a stream wrapping the uploaded file's contents
public
getStream() : StreamInterface
Tags
Return values
StreamInterfacemoveTo()
Move the uploaded file to a new location
public
moveTo(string $targetPath[, bool $secure = false ]) : void
Parameters
- $targetPath : string
- $secure : bool = false