But that function returns an array, or “on failure, false is returned” so for some reason, your call is failing. But then the var_dump you posted suggests that tmp_name is empty, so that’s probably it. Is there an upload file size limit on the server that prevents things happening over 50kb?
$check = getimagesize($_FILES["upload"]["tmp_name"]);
if($check == false) {
echo '<div class="alert alert-danger" role="alert">File is not an image.</div>';
$uploadOk = 0;
}
is run and not
if ($_FILES["upload"]["size"] > $_POST["MAX_FILE_SIZE"]) {
echo '<div class="alert alert-danger" role="alert">Sorry, your file is too large.</div>';
$uploadOk = 0;
}
Because the MAX_FILE_SIZE tells the browser not to upload the file if it’s larger than that size (I think), and so when your code executes the file has not been uploaded, hence you get a false return when you try to get the imagesize, because tmp_name is empty.
if ($_FILES["upload"]["size"] > $_POST["MAX_FILE_SIZE"]) {
echo '<div class="alert alert-danger" role="alert">Sorry, your file is too large.</div>';
$uploadOk = 0;
}
so it looks like the problem was that when I was using MAX_POST_SIZE (as a hidden input field in the form, a large file would simply return an error (making my if($_FILES[“upload”][“size”] > $_POST[“MAX_FILE_SIZE”] totally useless