Fr3nch13/CakePHP Utilities

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

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
throws
InvalidArgumentException

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.

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
see
http://php.net/is_uploaded_file
see
http://php.net/move_uploaded_file
throws
UploadedFileErrorException

If the upload was not successful.

throws
InvalidArgumentException

If the $path specified is invalid.

throws
UploadedFileErrorException

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

writeFile()

Write internal stream to given path

private writeFile(string $path) : void
Parameters
$path : string

        
On this page

Search results