Methods summary
public
|
#
__construct( string $fileName = '' )
Constructor
Parameters
- $fileName
- Path to the file
Overrides
SplFileInfo::__construct()
|
public
object
|
#
set( string $key, mixed $value )
Setter for the class properties
Setter for the class properties
Parameters
- $key
- The property name
- $value
- The value to be set
Returns
object
|
public
mixed
|
#
get( string $key )
Getter for the class properties
Getter for the class properties
Parameters
Returns
mixed $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
|
public
array
|
#
getError( )
Getter for the property error
Getter for the property error
Returns
array The array of error information
array(
'code' => 'Error code',
'message' => 'Error message'
)
|
public
string
|
#
getErrorMessage( integer $code )
Get file upload error message for the given error code
Get file upload error message for the given error code
Parameters
Returns
string The error message
|
public
array
|
#
upload( string|array $file )
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
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
array The array of the uploaded file information:
array(
'name' => 'Name of the input element',
'fileName' => 'The uploaded file name',
'originalFileName' => 'The original file name user selected',
'extension'=> 'The selected and uploaded file extension',
'dir' => 'The uploaded directory',
)
|
public
string
|
#
guessExtension( string $file = '' )
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
string The extension or an empty string if there is no file
|
protected
string
|
#
move( string $file, string $newFileName )
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
string The new file name or null if any error occurs
|
protected
string
|
#
resizeImageByDimension( string|array $dimensions, string $file, string $newFileName, string $extension = null )
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
string The new file name or null if any error occurs
|
public static
resource
|
#
resizeImageWidth( resource & $img, string $file, integer $newWidth, string $extension = null )
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
resource An image resource identifier on success, FALSE on errors
|
public static
resource
|
#
resizeImageHeight( resource & $img, string $file, integer $newHeight, string $extension = null )
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
resource An image resource identifier on success, FALSE on errors
|
public static
resource
|
#
resizeImageBoth( resource & $img, string $file, integer $newWidth, integer $newHeight, string $extension = null )
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
resource An image resource identifier on success, FALSE on errors
|
public static
string
|
#
img( string $fileName, string $caption, integer $dimension, string $desiredDimension = '0x0', array $attributes = array() )
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
string The tag
|
Methods inherited from SplFileInfo
__toString(),
_bad_state_ex(),
getATime(),
getBasename(),
getCTime(),
getExtension(),
getFileInfo(),
getFilename(),
getGroup(),
getInode(),
getLinkTarget(),
getMTime(),
getOwner(),
getPath(),
getPathInfo(),
getPathname(),
getPerms(),
getRealPath(),
getSize(),
getType(),
isDir(),
isExecutable(),
isFile(),
isLink(),
isReadable(),
isWritable(),
openFile(),
setFileClass(),
setInfoClass()
|