phasync
UploadedFile / __construct

Method

UploadedFile::__construct

Creates an uploaded file.

Description#

public UploadedFile::__construct(
    mixed $source,
    ?string $clientFilename = null,
    ?string $clientMediaType = null,
    ?int $size = null,
    ?int $error = null,
    bool $isUploadedFile = false
)

Parameters#

$source mixed
Stream resource, file path (tmp_name), or stream
$clientFilename ?string = null
Client-reported filename
$clientMediaType ?string = null
Client-reported MIME type
$size ?int = null
File size in bytes
$error ?int = null
Upload error code (an UPLOAD_ERR_* constant); null is UPLOAD_ERR_OK
$isUploadedFile bool = false
True to let moveTo() move a path that PHP did not receive as an upload (rename()); a path is otherwise moved only with move_uploaded_file(), or in the CLI with rename()

Errors / Exceptions#

ExceptionWhen
InvalidArgumentExceptionWhen $source is a path that does not exist (not for an upload that failed)