UploadedFile
in package
implements
UploadedFileInterface
Table of Contents
Interfaces
- UploadedFileInterface
- Value object representing a file uploaded through an HTTP request.
Constants
- ERROR_MESSAGES = [\UPLOAD_ERR_OK => 'There is no error, the file uploaded with success', \UPLOAD_ERR_INI_SIZE => 'The uploaded file exceeds the upload_max_filesize directive in php.ini', \UPLOAD_ERR_FORM_SIZE => 'The uploaded file exceeds the MAX_FILE_SIZE directive that was ' . 'specified in the HTML form', \UPLOAD_ERR_PARTIAL => 'The uploaded file was only partially uploaded', \UPLOAD_ERR_NO_FILE => 'No file was uploaded', \UPLOAD_ERR_NO_TMP_DIR => 'Missing a temporary folder', \UPLOAD_ERR_CANT_WRITE => 'Failed to write file to disk', \UPLOAD_ERR_EXTENSION => 'A PHP extension stopped the file upload.']
Properties
- $clientFilename : string|null
- $clientMediaType : string|null
- $error : int
- $file : string|null
- $moved : bool
- $size : int
- $stream : null|StreamInterface
Methods
- __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.
- moveTo() : void
- Move the uploaded file to a new location.
- writeFile() : void
- Write internal stream to given path
Constants
ERROR_MESSAGES
public
mixed
ERROR_MESSAGES
= [\UPLOAD_ERR_OK => 'There is no error, the file uploaded with success', \UPLOAD_ERR_INI_SIZE => 'The uploaded file exceeds the upload_max_filesize directive in php.ini', \UPLOAD_ERR_FORM_SIZE => 'The uploaded file exceeds the MAX_FILE_SIZE directive that was ' . 'specified in the HTML form', \UPLOAD_ERR_PARTIAL => 'The uploaded file was only partially uploaded', \UPLOAD_ERR_NO_FILE => 'No file was uploaded', \UPLOAD_ERR_NO_TMP_DIR => 'Missing a temporary folder', \UPLOAD_ERR_CANT_WRITE => 'Failed to write file to disk', \UPLOAD_ERR_EXTENSION => 'A PHP extension stopped the file upload.']
Properties
$clientFilename
private
string|null
$clientFilename
= null
$clientMediaType
private
string|null
$clientMediaType
= null
$error
private
int
$error
$file
private
string|null
$file
= null
$moved
private
bool
$moved
= false
$size
private
int
$size
$stream
private
null|StreamInterface
$stream
Methods
__construct()
public
__construct(string|resource|StreamInterface $streamOrFile, int $size, int $errorStatus[, string|null $clientFilename = null ][, string|null $clientMediaType = null ]) : mixed
Parameters
- $streamOrFile : string|resource|StreamInterface
- $size : int
- $errorStatus : int
- $clientFilename : string|null = null
- $clientMediaType : string|null = null
Tags
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.
getError()
Retrieve the error associated with the uploaded file.
public
getError() : int
Tags
Return values
int —One of PHP's UPLOAD_ERR_XXX constants.
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
Return values
StreamInterface —Stream representation of the uploaded file.
moveTo()
Move the uploaded file to a new location.
public
moveTo(string $targetPath) : void
Parameters
- $targetPath : string
-
Path to which to move the uploaded file.
Tags
writeFile()
Write internal stream to given path
private
writeFile(string $path) : void
Parameters
- $path : string