I am working on a PHP upload script and when testing my error checks, I attempted to upload a 17MB TIFF file. When I do this the $_FILES array is empty. The script works fine for what I need it to do, which is to upload JPEG files. My solution is to test if $_FILES is empty or not before continuing with the upload script.
Can anybody explain why $_FILES is empty when a TIFF is attempted to be uploaded? Is my solution, to check if $_FILES is empty or not, an okay one?
Does this have something to do with settings in php.ini?
Just to clarify
I was checking that $_FILES was empty using the following:
if(empty($_FILES))
{
die('$_FILES is empty.');
}
Yes, upload_max_filesize controls max upload size, which the TIFF file most likely exceeded. The default is 2M. You can test with:
EDIT: Actually, the exact cause is more likely post_max_size, which is always >= upload_max_filesize: “If the size of post data is greater than post_max_size, the $_POST and $_FILES superglobals are empty.”