Index Documentation

HttpUploadedFile
in package

Represents an uploaded file in a multipart/form-data request.

Table of Contents

Methods

__construct()  : mixed
createFromPhpFiles()  : array<string, HttpUploadedFile|array<string, mixed>>
Creates a collection of HttpUploadedFile instances from the $_FILES superglobal.
createFromPhpFilesEntry()  : HttpUploadedFile
Creates a HttpUploadedFile instance from an entry in the $_FILES superglobal.
getErrorCode()  : int
Retrieves the PHP file upload error code.
getLocalFileName()  : string|null
Retrieves the local path to the uploaded file.
getLocalMediaType()  : MediaType|null
Retrieves media type of the uploaded file.
getSize()  : int
Retrieves the size of the uploaded file.
getSuggestedFileName()  : string
Retrieves the suggested name for the uploaded file.
getSuggestedMediaType()  : MediaType
Retrieves the suggested media type for the uploaded file.
hasMoved()  : bool
Checks whether the file has been moved to its final destination.
moveTo()  : void
Moves the uploaded file to its final destination.

Methods

__construct()

public __construct(int $errorCode, int $size, string $localFileName, string $suggestedFileName, MediaType|string $suggestedMediaType) : mixed
Parameters
$errorCode : int

PHP file upload error code.

$size : int

Size, as provided by the client.

$localFileName : string

Filename generated by PHP on the server.

$suggestedFileName : string

Filename included by the client.

$suggestedMediaType : MediaType|string

Mediatype included by the client.

createFromPhpFiles()

Creates a collection of HttpUploadedFile instances from the $_FILES superglobal.

public static createFromPhpFiles(array<string, mixed> $files) : array<string, HttpUploadedFile|array<string, mixed>>
Parameters
$files : array<string, mixed>

Value of a $_FILES superglobal.

Return values
array<string, HttpUploadedFile|array<string, mixed>>

Uploaded files.

createFromPhpFilesEntry()

Creates a HttpUploadedFile instance from an entry in the $_FILES superglobal.

public static createFromPhpFilesEntry(array<string, int|string> $file) : HttpUploadedFile
Parameters
$file : array<string, int|string>

File info array.

Return values
HttpUploadedFile

Uploaded file info.

getErrorCode()

Retrieves the PHP file upload error code.

public getErrorCode() : int
Return values
int

PHP file upload error code.

getLocalFileName()

Retrieves the local path to the uploaded file.

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

Path to file, or null.

getLocalMediaType()

Retrieves media type of the uploaded file.

public getLocalMediaType() : MediaType|null
Return values
MediaType|null

Type of file, or null.

getSize()

Retrieves the size of the uploaded file.

public getSize() : int
Return values
int

Size of uploaded file.

getSuggestedFileName()

Retrieves the suggested name for the uploaded file.

public getSuggestedFileName() : string
Return values
string

Suggested name for the file.

getSuggestedMediaType()

Retrieves the suggested media type for the uploaded file.

public getSuggestedMediaType() : MediaType
Return values
MediaType

Suggested type for the file.

hasMoved()

Checks whether the file has been moved to its final destination.

public hasMoved() : bool
Return values
bool

true if it has been moved.

moveTo()

Moves the uploaded file to its final destination.

public moveTo(string $path) : void
Parameters
$path : string

Path to move the file to.

Tags
throws
RuntimeException

If the file has already been moved.

throws
RuntimeException

If an upload error occurred.

throws
InvalidArgumentException

If the provided $path is not valid.

throws
RuntimeException

If the file failed to move.


        
On this page

Search results