I'm a little tired so I don't see any straightout errors, but try to start from the ground up:
Make sure the <form> element starts as so:
<form action="???.php" method="post" enctype="multipart/form-data">
Then for testing, why not dump the $_FILES['screenshot'] element?:
<?php
print "<pre>";
print_r($_FILES['screenshot']);
?>This should help you debug problems, keep it up while you're writing your script, as you can attribute each problem to the actual facts.
As for the way you structured your IF statements, I'm not sure if it'd work or not, try something basic such as:
//One megabyte
$MAX_FILE_SIZE = 1048576;
//Allowed Mimetypes
$allowedTypes = Array("image/jpeg", "image/pjpeg", "image/gif", "image/png");
//Check for upload errors:
if ($_FILES["screenshot"]["errors"] > 0) {
print '<p class="error">Problem uploading image file, please try again later.</p>';
}
//Check filesize
if($_FILES["screenshot"]["size"] > $MAX_FILE_SIZE) {
print '<p class="error">File size too big, Please choose a smaller file.</p>';
}
//Check finally the mimetypes:
if(!in_array($_FILES['screenshot']['type'], $allowedTypes)) {
print '<p class="error">Invalid file type. Supported file types are '
. 'JPEG, GIF or PNG.</p>';
}
Should be cleaner and that should allow better insight into what is happening, add the print_r statement if you wish to debug of course with this code.
::EDIT::::
As per your original code; you used OR (
||) in your statements, which would mean if it was gif, it still would not be jpeg or png, so the OR statement should be AND (
&&).
Glad coffee helped me. :P