|
Moodle
2.2.1
http://www.collinsharper.com
|
Public Member Functions | |
| upload_manager ($inputname='', $deleteothers=false, $handlecollisions=false, $course=null, $recoverifmultiple=false, $modbytes=0, $silent=false, $allownull=false, $allownullmultiple=true) | |
| preprocess_files () | |
| validate_file (&$file) | |
| save_files ($destination) | |
| process_file_uploads ($destination) | |
| delete_other_files ($destination, $exceptions=null) | |
| handle_filename_collision ($destination, &$file) | |
| check_before_renaming ($destination, $nametocheck, $file) | |
| get_file_upload_error (&$file) | |
| print_upload_log ($return=false, $skipemptyifmultiple=false) | |
| get_new_filename () | |
| get_new_filepath () | |
| get_original_filename () | |
| get_errors () | |
Data Fields | |
| $files | |
| $config | |
| $status | |
| $course | |
| $inputname | |
| $notify | |
Definition at line 36 of file uploadlib.php.
| check_before_renaming | ( | $ | destination, |
| $ | nametocheck, | ||
| $ | file | ||
| ) |
This function checks a potential filename against what's on the filesystem already and what's been saved already.
| string | $destination | Destination directory (to check existing files against) |
| string | $nametocheck | The filename to be compared. |
| object | $file | The current file from $files we're processing. return boolean |
Definition at line 364 of file uploadlib.php.

| delete_other_files | ( | $ | destination, |
| $ | exceptions = null |
||
| ) |
Deletes all the files in a given directory except for the files in $exceptions (full paths)
| string | $destination | The directory to clean up. |
| array | $exceptions | Full paths of files to KEEP. |
Definition at line 299 of file uploadlib.php.


| get_errors | ( | ) |
This function returns any errors wrapped up in red.
Definition at line 493 of file uploadlib.php.

| get_file_upload_error | ( | &$ | file | ) |
?
| object | $file | Passed in by reference. The current file from $files we're processing. |
probably a dud file name
Definition at line 389 of file uploadlib.php.
| get_new_filename | ( | ) |
If we're only handling one file (if inputname was given in the constructor) this will return the (possibly changed) filename of the file.
Definition at line 460 of file uploadlib.php.
| get_new_filepath | ( | ) |
If we're only handling one file (if input name was given in the constructor) this will return the full path to the saved file.
Definition at line 471 of file uploadlib.php.
If we're only handling one file (if inputname was given in the constructor) this will return the ORIGINAL filename of the file.
Definition at line 482 of file uploadlib.php.
| handle_filename_collision | ( | $ | destination, |
| &$ | file | ||
| ) |
Handles filename collisions - if the desired filename exists it will rename it according to the pattern in $format
| string | $destination | Destination directory (to check existing files against) |
| object | $file | Passed in by reference. The current file from $files we're processing. |
Definition at line 326 of file uploadlib.php.


| preprocess_files | ( | ) |
Gets all entries out of $_FILES and stores them locally in $files and then checks each one against get_max_upload_file_size() and calls cleanfilename() and scans them for viruses etc. $CFG $_FILES
Definition at line 120 of file uploadlib.php.


| print_upload_log | ( | $ | return = false, |
| $ | skipemptyifmultiple = false |
||
| ) |
prints a log of everything that happened (of interest) to each file in _FILES
| $return | - optional, defaults to false (log is echoed) |
Definition at line 440 of file uploadlib.php.
| process_file_uploads | ( | $ | destination | ) |
Wrapper function that calls preprocess_files() and viruscheck_files() and then save_files() Modules that require the insert id in the filepath should not use this and call these functions seperately in the required order. string $destination Where to save the uploaded files to.
Definition at line 286 of file uploadlib.php.

| save_files | ( | $ | destination | ) |
Moves all the files to the destination directory.
$CFG $USER
| string | $destination | The destination directory. |
Definition at line 212 of file uploadlib.php.


| upload_manager | ( | $ | inputname = '', |
| $ | deleteothers = false, |
||
| $ | handlecollisions = false, |
||
| $ | course = null, |
||
| $ | recoverifmultiple = false, |
||
| $ | modbytes = 0, |
||
| $ | silent = false, |
||
| $ | allownull = false, |
||
| $ | allownullmultiple = true |
||
| ) |
Constructor, sets up configuration stuff so we know how to act.
Note: destination not taken as parameter as some modules want to use the insertid in the path and we need to check the other stuff first.
$CFG
| string | $inputname | If this is given the upload manager will only process the file in $_FILES with this name. |
| boolean | $deleteothers | Whether to delete other files in the destination directory (optional, defaults to false) |
| boolean | $handlecollisions | Whether to use handle_filename_collision() or not. (optional, defaults to false) |
| course | $course | The course the files are being uploaded for (for logging and virus notifications) $COURSE |
| boolean | $recoverifmultiple | If we come across a virus, or if a file doesn't validate or whatever, do we continue? optional, defaults to true. |
| int | $modbytes | Max bytes for this module - this and $course->maxbytes are used to get the maxbytes from get_max_upload_file_size(). |
| boolean | $silent | Whether to notify errors or not. |
| boolean | $allownull | Whether we care if there's no file when we've set the input name. |
| boolean | $allownullmultiple | Whether we care if there's no files AT ALL when we've got multiples. This won't complain if we have file 1 and file 3 but not file 2, only for NO FILES AT ALL. |
Definition at line 89 of file uploadlib.php.

| validate_file | ( | &$ | file | ) |
Validates a single file entry from _FILES
| object | $file | The entry from _FILES to validate |
Definition at line 189 of file uploadlib.php.

| array $config |
Holds all configuration stuff
Definition at line 47 of file uploadlib.php.
The course this file has been uploaded for. $COURSE (for logging and virus notifications)
Definition at line 59 of file uploadlib.php.
| array $files |
Array to hold local copies of stuff in $_FILES
Definition at line 42 of file uploadlib.php.
| string $inputname |
If we're only getting one file. (for logging and virus notifications)
Definition at line 65 of file uploadlib.php.
| string $notify |
If we're given silent=true in the constructor, this gets built up to hold info about the process.
Definition at line 71 of file uploadlib.php.
| boolean $status |
Keep track of if we're ok (errors for each file are kept in $files['whatever']['uploadlog']
Definition at line 53 of file uploadlib.php.