The FileUpload class can be used to easily manage file uploads with the PHP engine. The FileUpload class can be used individually or can be used together with the FileUploadController class for more functionality.
Located in /fileupload.class.php (line 14)
The contructor loads the $_FILES array as an reference into a local variable inside the class.
Adds a new error to the array
Valid filetypes can be added to the object by using this function.
The function's first argument can accept a string together with an array of mimetypes as the second argument. Else one can input an array with extension => array(mimetypes) as the first argument.
Adds a new uploaded file to the array
Generates a directory structure on the server according to the full path given in the parameter. existing directories aren't touched.
New directories will be given default chmod.
This function returns an array with errors if they occured, if no errors were encountered this function will return false. Remember that rollback entries will only be entered after the move() has been initiated.
Extracts the extension of the filename provided
Returns the highest filenumber in the given directory. If the directory is empty, it will return the value 0.
Checks if a given directory is empty (has no files/dirs in it)
Checks if the file extension and mimetype are allowed
This is the main function which checks all the factors of the file(s) and moves them.
This function prepares the filename. It checks if the extension should be casted to lowercase and returns the correct filename.
Lists the contents of a given directory.
Rollback deletes any uploaded pictures and destroys the empty directories which are left. It does not touch any other directories which are not empty and it doesn't delete any directories other than the ones provided when issuing the move() command.
If the bIgnoreEmptyUploads is set to true, errors which are caused
with the errorcode 4 (no file uploaded) will not be added to the error array. This can be usefull if you use a static ammount of fields for multiple file uploads and you're using the rollback() function if any errors occured. Because a not-uploaded error doesn't always have to be a real error.
If the bLowerCaseExtension is set to true, extensions of file uploads will be casted to lowercase. This can be usefull if you do not wish to check if the file has the extension .JPG or .jpg for example.
Sets the maximum size in bytes the uploaded file(s) must comply to
Sets the new name(s) or naming method for the files being uploaded.
If only one file is being uploaded and the first argument is a string that name will be used for the uploaded file.
If multiple files are being uploaded you can feed an array of names to this function which will be used for the uploaded files. If your array with names is shorter than the number of files being uploaded the class will use the original name for the files remaining.
You also have the option to enter 'alpha' or 'num' as a string when uploading an array of files. The new names of the files will be according to the type selected (alpha starts with 'a' and num starts with 1). This function can be usefull if you are using the class for an image gallery.
This function sets the startnumber from where the automatic numbering system should start counting.
If you have enabled the automatic numbering and you set the startnumber to 8 (example) the first uploaded file will get the number 8. If you set the startnumber to 'auto' it will autodetect the highest number a file has in the directory and will take that number +1 as a startnumber.
Documentation generated on Fri, 04 Aug 2006 17:49:23 +0200 by phpDocumentor 1.3.0RC3