<?php


if ($HTTP_POST_VARS['submit']) {
ÊÊprint_r($HTTP_POST_FILES);
ÊÊif (!is_uploaded_file($HTTP_POST_FILES['file']['tmp_name'])) {
ÊÊÊÊ$error = "You did not upload a file!";
ÊÊÊÊunlink($HTTP_POST_FILES['file']['tmp_name']);
ÊÊÊÊ// assign error message, remove uploaded file, redisplay form.
ÊÊ} else {
ÊÊÊÊ//a file was uploaded
ÊÊÊÊ$maxfilesize=10240;


ÊÊÊÊif ($HTTP_POST_FILES['file']['size'] > $maxfilesize) {
ÊÊÊÊÊÊ$error = "file is too large";
ÊÊÊÊ Êunlink($HTTP_POST_FILES['file']['tmp_name']);
ÊÊÊÊÊÊ// assign error message, remove uploaded file, redisplay form.
ÊÊÊÊ} else {
ÊÊÊÊÊÊif ($HTTP_POST_FILES['file']['type'] != "image/gif" AND $HTTP_POST_FILES['file']['type'] != "image/pjpeg") { 
ÊÊÊÊÊÊÊÊ$error = "This file type is not allowed";
ÊÊÊÊÊÊÊÊunlink($HTTP_POST_FILES['file']['tmp_name']);
ÊÊÊÊÊÊÊÊ// assign error message, remove uploaded file, redisplay form.
ÊÊÊÊÊÊ} else {
ÊÊÊÊÊÊÊ//File has passed all validation, copy it to the final destination and remove the temporary file:
ÊÊÊÊÊÊÊcopy($HTTP_POST_FILES['file']['tmp_name'],"/finallocation/".$HTTP_POST_FILES['file']['name']);
ÊÊÊÊÊÊÊunlink($HTTP_POST_FILES['file']['tmp_name']);
ÊÊÊÊÊÊÊprint "File has been successfully uploaded!";
ÊÊÊÊÊÊÊexit;
ÊÊÊÊÊ}
ÊÊÊ } 
Ê }
}
?>


<html>
<head></head>
<body>
<form action="<?=$PHP_SELF?>" method="post" enctype="multipart/form-data">
<?=$error?>
<br><br>
Choose a file to upload:<br>
<input type="file" name="file"><br>
<input type="submit" name="submit" value="submit">
</form>
</body>
</html>