I have the following code:
$filecheck = basename($_FILES['imagefile']['name']);
$ext = substr($filecheck, strrpos($filecheck, '.') + 1);
if (($ext == "jpg" || $ext == "gif" || $ext == "png") && ($_FILES["imagefile"]["type"] == "image/jpeg" || $_FILES["imagefile"]["type"] == "image/gif" || $_FILES["imagefile"]["type"] == "image/png") &&
($_FILES["imagefile"]["size"] < 2120000)){
} else {
echo "F2";
die();
}
What I need to do is check if the downloaded jpg / gif / png file is less than 2 megabytes in size.
If it is more than 2 megabytes or the wrong file type, I need to return / echo F2 (error code for api).
When I use the above code to process the jpg 70k file, it returns F2.
SUBNOTE
image im uploading has the extension .JPG. Could it be a factor? If so, how can I adapt to this?
source
share