i forgot the enctype= thingy in <form>
PHP Code:
if( isset( $_POST['Upload'] )) {
$upload_dir = $_SERVER['DOCUMENT_ROOT'] . "/test/images/";
$MaxFileSize = 8192000;
$filename = $_FILES['file']['name'];
$filesize = $_FILES['file']['size'];
$filetmpname = $_FILES['file']['tmp_name'];
$allowed_types = array( "jpg", "gif", "png" );
$filetype = substr($filename, -3, 3);
if($filename) {
$error = 0;
if(($filesize > $MaxFileSize) || $filesize = 0 ) {
$error = 1;
$errmsg .= "Your File is to large, (Max File size: 8MB)";
}
if( !in_array( $filetype, $allowed_types )) {
$error = 1;
$errmsg .= "Your File is the wrong type, (Allowed Types: Gif, Jpg, Png)//change to the allowed types";
}else {
$error = 0;
}
if( $error == 1 ) {
die( "$errmsg" );
}else{
$num = rand( 1, 9999 );
$new_filename = $num.$filename;
$upload = move_uploaded_file($filetmpname, "$upload_dir$new_filename");
if( $upload ) {
echo 'Upload Succesfull';
//echo "<meta http-equiv='refresh' content='0; URL=?image=$upload_dir$new_filename'>";
}else {
die( "Cound not upload the file, please try again" );
}
}
}else{
echo "File '$filename' not uploaded";
}
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<center>
<form enctype="multipart/form-data" action="uploadform.php" method="post">
<input type="file" name="file"><br />
JPG, GIF, PNG uploadable files.<br />
<input type="checkbox" name="Thumbnail"> Thumbnails option<br />
<input type="checkbox" name="Watermarking"> Watermarking option<br />
<input type="submit" name="Upload" value="Upload File">
</form></center>
</body>
</html>