i have this script for an image validation. works fine with images with 500 kb or 1.5 mb for example, but if i try with images with 4mb or 6 for example, give the error Invalid format and not the “size large”. Why?
$imageData = @getimagesize($_FILES["userfile"]["tmp_name"]);
if($imageData === FALSE || !($imageData[2] == IMAGETYPE_GIF || $imageData[2] == IMAGETYPE_JPEG || $imageData[2] == IMAGETYPE_PNG)) {
echo "<li>Invalid format</li>";
die();
}
else {
if($_FILES["userfile"]["size"] >= 2000000) {
echo "<li>The size large</li>";
die();
}
else {
//mystuff
}
thanks
You might also want to check your post_max_size and upload_max_filesize in php.ini. If the files you are trying to upload are too large, then I believe the _FILES array will not be populated.