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 725)


	
			
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 737)

Array of allowed mimetypes (unset = any types)

mixed $destination_dir = "." (line 733)

Destination dir to put files

mixed $errcode = UPLOAD_E_OK (line 749)

Error code. Check to see if error occurred.

mixed $errmsg = array() (line 751)

Error message array, goes with errcode.

mixed $fieldname = "" (line 739)

Upload field name

mixed $filename = "" (line 741)

Original filename

mixed $filepath = "" (line 747)

Upload path to the file on the server

mixed $filesize = 0 (line 745)

Physical size of the file (bytes)

mixed $hasfiles = false (line 731)

True if some files were uploaded

mixed $max_size = 0 (line 735)

Max filesize, else delete (0 = any size)

mixed $mimetype = "" (line 743)

Mime type of the the file

mixed $uploaded (line 727)

Array of info on uploaded files

mixed $uploaded_count = 0 (line 729)

No. of files uploaded

Methods
Constructor fileupload (line 763)

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 962)

Return any error message(s).

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

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 888)

Acquire the details on the first upload file.

boolean get_first ()
get_last (line 932)

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 902)

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 917)

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 807)

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 798)

Set the maximum filesize allowed

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

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 1031)

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