Documentation Easy PHP Upload

Easy to use upload functions for (multiple) file upload with validation.

Example (simple use, uploading one file):

Variables (upload_class.php)

$the_file

The name of the original (uploaded) file

$the_temp_file

The temporay name of the uploaded file

$file_copy

This var holds the new name after upload (note this name can different form the uploaded fileif you rename/copy the file)
Use always this variable if you store somewhere the filename!

$upload_dir

The directory where the file will be uploaded

$replace

Set this var to true if an existing file should be replaced (default = false)

$do_filename_check

This var is used as a switch, possible setting y/n. In position 'y' the name is validated while using regular expressions.

$max_length_filename

Set this value to take care of the maximum length of a filename (default = 100)

$extensions

This array holds all file extensions, you can add so much as you want.

$ext_string

This var is used for output (to show which extensions are allowed)

$language

You need this var if your messages should be in an other language then English

$http_error

This variable is required, this var holds the error reported in by $_FILES array.

$rename_file

Set this boolean if you want to (auto)rename a file (i use a timestamp is name)

$message

This array is a container for all messages generated during the upload process.

$create_directory

Switch this boolean to create the upload directory if it doesn't exist (one level above)

Methodes (upload_class.php)

file_upload()

The constructor, sets the language, the rename boolean and empties the file extension string.

error_text($err_num)

This method is a multilanguage error selector, the property holds the error number

show_error_string()

This method is used to show all strings inside the message array

set_file_name($new_name = "")

checks if a custom filename exists, sets a default (new) filename or keeps the original one

upload($to_name = "")

This method is used to handle the upload process, $to_name is an additional custom name parameter (works together with the rename boolean)

check_file_name()

Checks the "spelling" of a filename the length and that the name is not empty.

get_extension($from_file)

Isolate the files extension with this method

validateExtension()

This method checks for a valid file extension

show_extensions()

Use this method to build the extension string

move_upload($tmp_file, $new_file)

This method is a group of functions which move the temporary file to his upload direction.

check_dir()

Check if the upload directory exists or not

existing_file()

This method checks if a file exists

 

updated in januar 2006