Methods |
public
|
__construct(string $fileName = '')
Constructor
Parameters
$fileName |
Path to the file
|
Overrides
|
#
|
public
|
set(string $key, mixed $value): object
Setter for the class properties
Setter for the class properties
Parameters
$key |
The property name
|
$value |
The value to be set
|
|
#
|
public
|
get(string $key): mixed
Getter for the class properties
Getter for the class properties
Parameters
Returns
$value The value of the property or null if $name does not exist.
|
#
|
public
|
getOriginalFileName()
Getter for the original uploaded file name
Getter for the original uploaded file name
|
#
|
public
|
getFileName()
Getter for the file name generated
Getter for the file name generated
Overrides
|
#
|
public
|
getError(): array
Getter for the property `error`
Getter for the property error
Returns
The array of error information
|
#
|
public
|
getErrorMessage(int $code): string
Get file upload error message for the given error code
Get file upload error message for the given error code
Parameters
Returns
|
#
|
public
|
upload(string|array $file): array
Move the uploaded file into the given directory.
If the uploaded file is image, this will create the various images…
Move the uploaded file into the given directory.
If the uploaded file is image, this will create the various images according to the given $dimension
Parameters
$file |
The name 'xxx' from $_FILES['xxx']
or The array of uploaded file information from $_FILES['xxx']
|
Returns
The array of the uploaded file information:
|
#
|
public
|
guessExtension(string $file = ''): string
Return the extension of the original file name
Return the extension of the original file name
Parameters
$file |
The optional file name; if it is not given, the original file name will be used
|
Returns
The extension or an empty string if there is no file
|
#
|
protected
|
move(string $file, string $newFileName): string
Move the uploaded file to the new location with new file name
Move the uploaded file to the new location with new file name
Parameters
$file |
The source file
|
$newFileName |
The new file name
|
Returns
The new file name or null if any error occurs
|
#
|
protected
|
resizeImageByDimension(string|array $dimensions, string $file, string $newFileName, string $extension = null): string
Resize the image file into the given width and height
Resize the image file into the given width and height
Parameters
$dimensions |
The dimension or array of dimensions,
e.g., '400x250' or array('400x250', '200x150')
|
$file |
The source file
|
$newFileName |
The new file name to be created
|
$extension |
The file extension
|
Returns
The new file name or null if any error occurs
|
#
|
public
static
|
resizeImageWidth(resource &$img, string $file, int $newWidth, string $extension = null): resource
Resize an image to a desired width and height by given width
Resize an image to a desired width and height by given width
Parameters
$img |
The image resource identifier
|
$file |
The image file name
|
$newWidth |
The new width to resize
|
$extension |
The file extension
|
Returns
An image resource identifier on success, FALSE on errors
|
#
|
public
static
|
resizeImageHeight(resource &$img, string $file, int $newHeight, string $extension = null): resource
Resize an image to a desired width and height by given height
Resize an image to a desired width and height by given height
Parameters
$img |
The image resource identifier
|
$file |
The image file name
|
$newHeight |
The new height to resize
|
$extension |
The file extension
|
Returns
An image resource identifier on success, FALSE on errors
|
#
|
public
static
|
resizeImageBoth(resource &$img, string $file, int $newWidth, int $newHeight, string $extension = null): resource
Resize an image to a desired width and height by given width and height
Resize an image to a desired width and height by given width and height
Parameters
$img |
The image resource identifier
|
$file |
The image file name
|
$newWidth |
The new width to resize
|
$newHeight |
The new height to resize
|
$extension |
The file extension
|
Returns
An image resource identifier on success, FALSE on errors
|
#
|
public
static
|
img(string $fileName, string $caption, int $dimension, string $desiredDimension = '0x0', array $attributes = []): string
Display an image fitting into the desired dimension
Display an image fitting into the desired dimension
Parameters
$fileName |
The file name with an absolute web path
|
$caption |
The image caption
|
$dimension |
The actual image dimension in "widthxheight"
|
$desiredDimension |
The desired dimension in "widthxheight"
|
$attributes |
The HTML attributes in array like key => value
|
Returns
The tag
|
#
|