![]() |
VOOZH | about |
final class FileUpload
Provides access to individual files that have been uploaded by a client.
| IMAGE_MIME_TYPES |
|
| string read-only | $name |
| string read-only | $sanitizedName |
| string read-only | $untrustedFullPath |
| ?string read-only | $contentType |
| int read-only | $size |
| string read-only | $temporaryFile |
| int read-only | $error |
| bool read-only | $ok |
| ?string read-only | $contents |
No description
No description
Returns the original file name as submitted by the browser. Do not trust the value returned by this method.
Returns the sanitized file name. The resulting name contains only ASCII characters [a-zA-Z0-9.-].
Returns the original full path as submitted by the browser during directory upload. Do not trust the value returned by this method. A client could send a malicious directory structure with the intention to corrupt or hack your application.
Detects the MIME content type of the uploaded file based on its signature. Requires PHP extension fileinfo.
Returns the appropriate file extension (without the period) corresponding to the detected MIME type. Requires the PHP extension fileinfo.
Returns the size of the uploaded file in bytes.
Returns the path of the temporary location of the uploaded file.
Returns the path of the temporary location of the uploaded file.
Returns the upload error code (one of the UPLOAD_ERR_XXX constants).
Returns true if the file was uploaded successfully.
Returns true if the user has uploaded a file.
Moves an uploaded file to a new location. If the destination file already exists, it will be overwritten.
Checks whether the uploaded file is an image in a format supported by PHP (detectable via fileinfo, loadable via GD).
Converts uploaded image to Nette\Utils\Image object.
Returns the [width, height] dimensions of the uploaded image, or null if it is not a valid image.
Returns image file extension based on detected content type (without dot).
Returns the contents of the uploaded file. If the upload was not successful, it returns null.
__construct(array|string|null $value)
No description
| array|string|null | $value |
string
getName()
No description
| string |
string
getUntrustedName()
Returns the original file name as submitted by the browser. Do not trust the value returned by this method.
A client could send a malicious filename with the intention to corrupt or hack your application.
| string |
string
getSanitizedName()
Returns the sanitized file name. The resulting name contains only ASCII characters [a-zA-Z0-9.-].
If the name does not contain such characters, it returns 'unknown'. If the file is an image supported by PHP, it returns the correct file extension. Do not blindly trust the value returned by this method.
| string |
string
getUntrustedFullPath()
Returns the original full path as submitted by the browser during directory upload. Do not trust the value returned by this method. A client could send a malicious directory structure with the intention to corrupt or hack your application.
| string |
string|null
getContentType()
Detects the MIME content type of the uploaded file based on its signature. Requires PHP extension fileinfo.
If the upload was not successful or the detection failed, it returns null.
| string|null |
string|null
getSuggestedExtension()
Returns the appropriate file extension (without the period) corresponding to the detected MIME type. Requires the PHP extension fileinfo.
| string|null |
int
getSize()
Returns the size of the uploaded file in bytes.
| int |
string
getTemporaryFile()
Returns the path of the temporary location of the uploaded file.
| string |
string
__toString()
Returns the path of the temporary location of the uploaded file.
| string |
int
getError()
Returns the upload error code (one of the UPLOAD_ERR_XXX constants).
bool
isOk()
Returns true if the file was uploaded successfully.
| bool |
bool
hasFile()
Returns true if the user has uploaded a file.
| bool |
FileUpload
move(string $dest)
Moves an uploaded file to a new location. If the destination file already exists, it will be overwritten.
bool
isImage()
Checks whether the uploaded file is an image in a format supported by PHP (detectable via fileinfo, loadable via GD).
Detection is based on file signature; full integrity is not verified.
| bool |
Image
toImage()
Converts uploaded image to Nette\Utils\Image object.
| Image |
| ImageException |
array|null
getImageSize()
Returns the [width, height] dimensions of the uploaded image, or null if it is not a valid image.
| array|null |
string|null
getImageFileExtension()
deprecated
deprecated use getSuggestedExtension()
Returns image file extension based on detected content type (without dot).
| string|null |
string|null
getContents()
Returns the contents of the uploaded file. If the upload was not successful, it returns null.
| string|null |