Class fileupload

Description

Fileupload class.

This is a class for handling file uploads. It assumes that one or more files have been uploaded and are being actioned by the current Php script which instantiates this object.

Located in /file-defs.php (line 674)


	
			
Variable Summary
 mixed $errcode
 mixed $errmsg
 mixed $fieldname
 mixed $filename
 mixed $filepath
 mixed $filesize
 mixed $hasfiles
 mixed $max_size
 mixed $mimetype
 mixed $uploaded
Method Summary
 boolean fileupload (integer $maxsize)
 string error_message ()
 boolean get_current ()
 boolean get_first ()
 boolean get_last ()
 boolean get_next ()
 boolean get_previous ()
 void set_allowed_types ([string $types = ""])
 void set_maxsize (integer $maxsize)
 boolean store ([string $destdir = ""], [string $filename = ""])
 boolean storeall ([string $destdir = ""])
Variables
mixed $allowed_types (line 686)

Array of allowed mimetypes (unset = any types)

mixed $destination_dir = "." (line 682)

Destination dir to put files

mixed $errcode = UPLOAD_E_OK (line 698)

Error code. Check to see if error occurred.

mixed $errmsg = array() (line 700)

Error message array, goes with errcode.

mixed $fieldname = "" (line 688)

Upload field name

mixed $filename = "" (line 690)

Original filename

mixed $filepath = "" (line 696)

Upload path to the file on the server

mixed $filesize = 0 (line 694)

Physical size of the file (bytes)

mixed $hasfiles = false (line 680)

True if some files were uploaded

mixed $max_size = 0 (line 684)

Max filesize, else delete (0 = any size)

mixed $mimetype = "" (line 692)

Mime type of the the file

mixed $uploaded (line 676)

Array of info on uploaded files

mixed $uploaded_count = 0 (line 678)

No. of files uploaded

Methods
Constructor fileupload (line 712)

Constructor. On instantiation this class checks the global variable space for uploaded file info and pre-processes it.

NB: You may specify a filesize limit with $maxsize. If you do then we do not take notice of the MAX_FILE_SIZE submitted from the form. This is recommended, since the form value can easily be hacked..

  • return: Status, true if all ok, else false.
boolean fileupload (integer $maxsize)
  • integer $maxsize: The maximum filesize in bytes
error_message (line 911)

Return any error message(s).

  • return: Error message text, or nullstring if no error.
string error_message ()
get_current (line 817)

Acquire the details on the current upload file. This includes the

original filename, its mimetype, its size and the full path on the webserver to which the file was uploaded. The details are populated in class variables: $this->fieldname $this->filename $this->mimetype $this->filesize $this->filepath And these variables are then available to be read/used by the calling application code.

  • return: True if info was obtained
boolean get_current ()
get_first (line 837)

Acquire the details on the first upload file.

boolean get_first ()
get_last (line 881)

Get details on the last file which was uploaded. If there are no more, then this function returns false.

boolean get_last ()
get_next (line 851)

Get details on the next file which was uploaded. If there are no more, then this function returns false.

boolean get_next ()
get_previous (line 866)

Get details on the previous file which was uploaded. If there are no more, then this function returns false.

boolean get_previous ()
set_allowed_types (line 756)

Set the allowed list of filetypes. This is specified as a comma-delimited list, and replaces any already defined.

void set_allowed_types ([string $types = ""])
  • string $types: The list of allowed mimetypes
set_maxsize (line 747)

Set the maximum filesize allowed

void set_maxsize (integer $maxsize)
  • integer $maxsize: The maximum filesize in bytes
store (line 926)

Store the current upload file. Optionally specify a destination dir, and a filename. This is useful if you want to process each file separately, and need to store the uploaded file in a particular place.

  • return: True if all was ok, store succeeded
boolean store ([string $destdir = ""], [string $filename = ""])
  • string $destdir: Destination directory path
  • string $filename: Destination filename (or default to uploaded filename)
storeall (line 980)

Store all files away at destination dir. We use the original names by default.

  • return: True if all was ok, store succeeded
boolean storeall ([string $destdir = ""])
  • string $destdir: Destination directory path

Documentation generated by phpDocumentor 1.3.0RC3