<?php
include ($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 = $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) 

		
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
	$my_upload->upload();
	// use the following if clause to do something if the upload is true
	/* if ($my_upload->upload()) { 
		do something ... like insert the filename to the database
	} */
}
?> 
<!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>Upload example</title>
</head>

<body>
<h3>File upload script:</h3>
<p>Max. filesize = <?php echo $max_size; ?> bytes.</p>
<form name="form1" enctype="multipart/form-data" method="post" action="<?php echo $PHP_SELF; ?>">
  <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_size; ?>">
  <input type="file" name="upload" size="30"><br>
  Replace ? <input type="checkbox" name="replace" value="y"><br>
  Validate filename ? 
  <input name="check" type="checkbox" value="y" checked>
  <input type="submit" name="Submit" value="Submit">
</form>
<p><?php echo $my_upload->show_error_string(); ?></p>
</body>
</html>