public function errorInfo()
// Return the last error message generated by any method
public function uploadFiles($upload_fileset_info, $dest_dir, $nameHandler, $postUploadHandler, $verbose = false)
/* Attempt to upload ONE OR MULTIPLE files to the specified destination directory.
Whenever each of the uploads is initially successful (got stored in a temporary file on the server), invoke the optional function stored in $nameHandler
RETURN VALUE: the number of successful uploads. In case of error, the property "errorMessage" is set to an explanation of the error
If any upload fails, the uploader skips to the next file upload
USAGE:
For a SINGLE file upload:
A) the calling form has a form with an entry such as: <INPUT type='file' name='myFile'>
B) the form-processing script contains: $upload_fileset_info = $_FILES["myFile"];
For a MULTIPLE file uploads:
A) the calling form has a set of entries such as: <INPUT type='file' name='myFileList[]'> (one per file to upload)
B) the form-processing script contains: $upload_fileset_info = $_FILES["myFileList"];
ARGUMENTS:
$upload_fileset_info (see USAGE, above)
$dest_dir a relative or absolute path in the file system, incl. the final "/" . (For the same folder, use "./") Any already-existing file with the same name will get over-written
$nameHandler If FALSE, it indicates "just use the same original name for the uploaded file"
If TRUE, it's expected to be the name of a function to invoke with 4 arguments: f($name, $tmp_name, $type, $size)
$name the original name of the file being uploaded
$tmp_name the temporary filename assigned by the server mid-upload (with full path)
$type the uploaded file's MIME type
$size size of uploaded file's size in Bytes
Tha function needs to return a file name to use for permanent file storage (possibly the same as the original name), or false in case of error (for example, a database error).
That function is also a convenient place for the invoking script to do all the necessary database operations.
$postUploadHandler name of a function that gets invoked upon a successful file upload (for example, to take care of additional database update). Use FALSE to indicate no function
$verbose whether to print out (in addition to logging) any information or error messages
$upload_fileset_info is an array of 5 elements, called:
"name",
"type",
"tmp_name",
"error",
"size"
Each element is either a value (in case of single uploads) or an array whose dimension equals the numbers of files being uploaded.
EXAMPLE of $upload_fileset_info in case of a SINGLE UPLOADED FILE:
Array
(
[name] => sample-file.doc
[type] => application/msword
[tmp_name] => /tmp/path/phpVGCDAJ
[error] => 0
[size] => 450
)
EXAMPLE of $upload_fileset_info in case of MULTIPLE FILES:
Array
(
[name] => Array
(
[0] => sample-file1.doc
[1] => focus.jpg
)
[type] => Array
(
[0] => application/msword
[1] => image/jpeg
)
[tmp_name] => Array
(
[0] => /tmp/phprS2u1w
[1] => /tmp/php3oOgSr
)
[error] => Array
(
[0] => 0
[1] => 0
)
[size] => Array
(
[0] => 22685
[1] => 30733
)
)
*/
public function uploadSingleFile($name, $type, $size, $tmp_name, $error, $dest_dir, $nameHandler, $postUploadHandler, $verbose = false)
/* The first 5 arguments are the standard $_FILES array component. For an explanation of the remaining arguments, see uploadFiles()
If a file with the requested name already exists, it gets overwritten.
Return 1 if upload is successful, or 0 if not (i.e. the number of successful uploads). In case of error, the property "errorMessage" is set to an explanation of the error
*/