class UploadedFile extends FileInfo

Uploaded file.

Properties

protected string $filename Filename.
protected int $size File size.
protected string $type File mime type.
protected int $errorCode File error code.

Methods

string|null
getMimeType()

Returns the MIME type of the file.

from FileInfo
string|null
getMimeEncoding()

Returns the MIME encoding of the file.

from FileInfo
string
getHash(string $algorithm = 'sha256', bool $raw = false)

Generates a hash using the contents of the file.

from FileInfo
bool
validateHash(string $hash, string $algorithm = 'sha256', bool $raw = false)

Returns TRUE if the file matches the provided hash and FALSE if not.

from FileInfo
string
getHmac(string $key, string $algorithm = 'sha256', bool $raw = false)

Generates a HMAC using the contents of the file.

from FileInfo
bool
validateHmac(string $hmac, string $key, string $algorithm = 'sha256', bool $raw = false)

Returns TRUE if the file matches the provided HMAC and FALSE if not.

from FileInfo
__construct(string $path, string $name, int $size, string $type, int $errorCode)

Constuctor.

string
getName() deprecated

Returns the filename.

string
getReportedFilename()

Returns the filename reported by the client.

int
getReportedSize()

Returns the size reported by the client in bytes.

string
getReportedType() deprecated

Returns the mime type reported by the client.

string
getReportedMimeType()

Returns the mime type reported by the client.

bool
hasError()

Does the file have an error?

int
getErrorCode()

Returns the file error code.

string
getErrorMessage()

Returns a human friendly error message.

bool
isUploaded()

Returns TRUE if the file has been uploaded and FALSE if not.

bool
moveUploadedFile(string $path)

Moves the file to the desired path.

bool
moveTo(string $path)

Moves the file to the desired path.

Details

in FileInfo at line 31
string|null getMimeType()

Returns the MIME type of the file.

Return Value

string|null

in FileInfo at line 47
string|null getMimeEncoding()

Returns the MIME encoding of the file.

Return Value

string|null

in FileInfo at line 65
string getHash(string $algorithm = 'sha256', bool $raw = false)

Generates a hash using the contents of the file.

Parameters

string $algorithm Hashing algorithm
bool $raw Output raw binary data?

Return Value

string

in FileInfo at line 78
bool validateHash(string $hash, string $algorithm = 'sha256', bool $raw = false)

Returns TRUE if the file matches the provided hash and FALSE if not.

Parameters

string $hash Hash
string $algorithm Hashing algorithm
bool $raw Is the provided hash raw?

Return Value

bool

in FileInfo at line 91
string getHmac(string $key, string $algorithm = 'sha256', bool $raw = false)

Generates a HMAC using the contents of the file.

Parameters

string $key Shared secret key
string $algorithm Hashing algorithm
bool $raw Output raw binary data?

Return Value

string

in FileInfo at line 105
bool validateHmac(string $hmac, string $key, string $algorithm = 'sha256', bool $raw = false)

Returns TRUE if the file matches the provided HMAC and FALSE if not.

Parameters

string $hmac HMAC
string $key Key
string $algorithm Hashing algorithm
bool $raw Is the provided HMAC raw?

Return Value

bool

at line 61
__construct(string $path, string $name, int $size, string $type, int $errorCode)

Constuctor.

Parameters

string $path File path
string $name Filename
int $size File size
string $type File mime type
int $errorCode File error code

at line 80
string getName() deprecated

deprecated 7.0

Returns the filename.

Return Value

string

at line 90
string getReportedFilename()

Returns the filename reported by the client.

Return Value

string

at line 100
int getReportedSize()

Returns the size reported by the client in bytes.

Return Value

int

at line 111
string getReportedType() deprecated

deprecated 7.0

Returns the mime type reported by the client.

Return Value

string

at line 121
string getReportedMimeType()

Returns the mime type reported by the client.

Return Value

string

at line 131
bool hasError()

Does the file have an error?

Return Value

bool

at line 141
int getErrorCode()

Returns the file error code.

Return Value

int

at line 151
string getErrorMessage()

Returns a human friendly error message.

Return Value

string

at line 181
bool isUploaded()

Returns TRUE if the file has been uploaded and FALSE if not.

Return Value

bool

at line 192
protected bool moveUploadedFile(string $path)

Moves the file to the desired path.

Parameters

string $path Storage path

Return Value

bool

at line 203
bool moveTo(string $path)

Moves the file to the desired path.

Parameters

string $path Storage path

Return Value

bool