NOFILE
NOFILE
A class to aide in dealing with uploaded files, including post processing of images.
__construct(\string $prefix, \string $destdir, \CGExtensions\watermarker $obj = null)
Constructor
| \string | $prefix | A common array key prefix for all files to be handled by this object. |
| \string | $destdir | The full path to the destination directory. |
| \CGExtensions\watermarker | $obj |
check_upload_attempted(string $name, string $subfield = null) : boolean
Check if a file has been uploaded with the specified field name.
If specified in the constructor a prefix will be prepended to this name for comparison. This method will not set any of the error members in the object.
| string | $name | The field name |
| string | $subfield | Assume that the prefix+field name represent an array |
check_upload(string $name, string $subfield = null, boolean $checkdir = TRUE) : boolean
Check if a file has been uploaded to the specified name, and if it is valid.
If specified in the constructor a prefix will be prepended to this name for comparison. This method will set internal error strings and numbers on failure.
| string | $name | The upload key name |
| string | $subfield | Assume that the prefix+field name represent an array |
| boolean | $checkdir | Test if the destination directory exists, and is writable. |
True on success, false on error.
handle_upload(string $name, string $destfilename = '', string $subfield = null) : string
Handle the upload of a file.
This method will generate thumbnails from images that are in the accepted filetypes.
| string | $name | The input field name from the form's input field of type FILE. |
| string | $destfilename | The destination filename. |
| string | $subfield | Assume that the prefix+field name represent an array |
The basename of the uploaded file.
get_file_record(string $field_name, string $subfield = null) : array|null
Given a field name, and a subfield.
. get the aggregated record from $_FILES so that the upload can be processed.
In the event of a problem this method sets the errno variable for error handling.
| string | $field_name | The input field name |
| string | $subfield | The name of any subfield. |
preprocess_upload(array $fileinfo) : string
Preprocess the uploaded image file. If the file is in the accepted image types.
by default this method will generate a preview image (if enabled), and then optionally watermark it.
| array | $fileinfo | The fileinfo array passed from the $_FILES upload global. |
The path and filename of the destination file.