<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Documentation Easy PHP Upload</title>
<style type="text/css">
<!--
h3 {
	margin-bottom: 0px;
}
p {
	margin-top: 0px;
}
textarea {
	border:1px solid #CCCCCC;
	width:640px;
	height:470px;
	font:12px Arial, Helvetica, sans-serif;
}
-->
</style>
</head>

<body>
<h1>Documentation Easy PHP Upload</h1>
<p>Easy to use upload functions for (multiple) file upload with validation.</p>
<h2>Example (simple use, uploading one file):</h2>
<form>
  <textarea wrap="VIRTUAL">
<?php
include ($_SERVER['DOCUMENT_ROOT']."/classes/upload/upload_class.php"); //classes is the map where the class file is stored (one above the root)

$max_size = 1024*100; // the max. size for uploading
	
$my_upload = new file_upload;

$my_upload->upload_dir = $_SERVER['DOCUMENT_ROOT']."/files/"; // "files" is the folder for the uploaded files (you have to create this folder)
$my_upload->extensions = array(".png", ".zip"); // specify the allowed extensions here
// $my_upload->extensions = "de"; // use this to switch the messages into an other language (translate first!!!)
$my_upload->max_length_filename = 50; // change this value to fit your field length in your database (standard 100) 
$my_upload->rename_file = true;
		
if(isset($Submit)) {
	$my_upload->the_temp_file = $_FILES['upload']['tmp_name'];
	$my_upload->the_file = $_FILES['upload']['name'];
	$my_upload->http_error = $_FILES['upload']['error'];
	$my_upload->replace = (isset($_POST['replace'])) ? $_POST['replace'] : "n"; // because only a checked checkboxes is true
	$my_upload->do_filename_check = (isset($_POST['check'])) ? $_POST['check'] : "n"; // use this boolean to check for a valid filename
	if ($my_upload->upload($new_name)) { // new name is an additional filename information, use this to rename the uploaded file
		$full_path = $my_upload->upload_dir.$my_upload->file_copy;
		$info = $my_upload->get_uploaded_file_info($full_path); // just some information about the uploaded file
		// ... or do something like insert the filename to the database
	}
}
?> 
  </textarea>
</form>
<h2>Variables (upload_class.php) </h2>
<h3>$the_file</h3>
<p>The name of the original (uploaded) file</p>
<h3>$the_temp_file</h3> 
<p>The temporay name of the uploaded file</p>
<h3>$file_copy</h3>
<p>This var holds the new name  after upload (note this name can different form the uploaded fileif you rename/copy the file)<br>
    <i>Use always this variable if you store somewhere the filename! </i></p>
<h3>$upload_dir</h3>
<p>The directory where the file will be uploaded. <b>NOTE: since version 2.27 a non existing directory will be created. But one level above the existing directory! </b></p>
<h3>$replace</h3>
<p>Set this var to true if an existing file should be replaced (default = false)</p>
<h3>$do_filename_check</h3>	
<p>This var is used as a switch, possible setting y/n. In position 'y' the name is validated while using regular expressions.</p>
<h3>$max_length_filename</h3>
<p>Set this value to take care of the maximum length of a filename (default = 100)</p>
<h3>$extensions</h3>
<p>This array holds all file extensions, you can add so much as you want.</p>
<h3>$ext_string</h3>
<p>This var is used for output (to show which extensions are allowed)</p>
<h3>$language</h3>
<p>You need this var if your messages should be in an other language then English</p>
<h3>$http_error</h3>
<p>This variable is required, this var holds the error reported in by $_FILES array.</p>
<h3>$rename_file</h3>
<p>Set this boolean if you want to (auto)rename a file (i use a timestamp is name)</p>
<h3>$message</h3>
<p>This array is a container for all messages generated during the upload process.</p>
<h3>$create_directory</h3>
<p>Switch this boolean to create the upload directory if it doesn't exist (one level above) </p>
<h2>Methodes (upload_class.php) </h2>
<h3>file_upload()</h3>
<p>The constructor, sets the language, the rename boolean and empties the file extension string.</p>
<h3>error_text($err_num)</h3>
<p>This method is a multilanguage error selector, the property holds the error number</p>
<h3>show_error_string()</h3>
<p>This method is used to show all strings inside the message array</p>
<h3><b>set_file_name($new_name = &quot;&quot;) </b></h3>
<p>  checks if a custom filename exists, sets a default (new) filename or keeps the original one </p>
<h3>upload($to_name = &quot;&quot;)</h3>
<p>This method is used to handle the upload process, $to_name is an additional custom name parameter (works together with the rename boolean) </p>
<h3>check_file_name()</h3>
<p>Checks the "spelling" of a filename the length and that the name is not empty.</p>
<h3>get_extension($from_file)</h3>
<p>Isolate the files extension with this method</p>
<h3>validateExtension()</h3>
<p>This method checks for a valid file extension</p>
<h3>show_extensions()</h3>
<p>Use this method to build the extension string</p>
<h3>move_upload($tmp_file, $new_file)</h3>
<p>This method is a group of functions which move the temporary file to his upload direction.</p>
<h3>check_dir()</h3>
<p>Check if the upload directory exists or not and if the boolean &quot;$create_directory&quot; is true the directory will be created. (new since version 2.27).</p>
<h3>existing_file()</h3>
<p>This method checks if a file exists</p>
<p>&nbsp;</p>
<p align="right">updated in januar 2006</p>
</body>
</html>
