NOFILE
NOFILE
A simple class to assist with handling PHP file uploads
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) : boolean
Handle preprocessing an uploaded file, test for errors and move the file to its destination location.
| string | $name | The upload key name |
| string | $destfilename | An optional destination filename. |
| string | $subfield | Assume that the prefix+field name represent an array |
True on success, false on error.
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 file.
If a preprocessor has been passed into this object, this method will preprocess the file
| array | $fileinfo | The file info record (from the $_FILES array) for the file to preprocess. |
The filename of the pre-processed file on success. Otherwise, FALSE