I've made some changes to the second file. The thing is i've set the maximum filesize to 400000 bytes. about 400kb right? And then i try to upload a picture that is 500kb to see if my error handling works. When i try the browser counts slow from 1% done to 100% and when it hits 100% nothing happends. I doesn't even come as far as to the second page.
2nd page:
<?
/* VARIABELS SETTINGS */
$max_filesize = 400000;
/* UPLOAD PROCEDURE */
if (is_uploaded_file($userfile_tmp_name)) {
if (($userfile_type == "image/jpeg") or ($userfile_type == "image/pjpeg") or ($userfile_type == "image/gif") or ($userfile_type == "image/png")) {
if ($userfile_size < $max_filesize) {
copy($userfile, "./photos/" . $userfile_name);
}
else { Header("Location: test2.php?error=3"); }
}
else { Header("Location: test2.php?error=2"); }
}
else { Header("Location: test2.php?error=1"); }
/* ERROR HANDLING */
switch ($error) {
case 1:
print "Possible file upload attack. Filename: " . $userfile_name;
break;
case 2:
print "Please only upload image (jpg,jpeg,png,gif) files." . "<br>" . "You tried to upload a file with type: ". $userfile_type;
break;
case 3:
print "Your file was to big, the maximum allowed filesize is ". $max_filesize . " bytes.";
break;
default:
print "Your image was successfully uploaded to the server.";
}
?>
1st page:
<form enctype="multipart/form-data" action="test2.php" method="post">
Send this file: <input name="userfile" type="file">
<input type="submit" value="Send File">
</form>