I want to put out an error message when the uploaded image size is over 3MB.
This is my current code. It puts out an error message properly when an image is over 3MB, but it also puts out an error message when no image is uploaded. How do I fix this?
//image check start
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/png")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 3072000))
//image check end
{
if($_FILES['file']['size'] > 0)
{
file uploading script
} else {
do nothing
}
} else {
error("Maximum image size exceeded or invalid file format.");
}
The problem was
in my php.ini file.
When I changed it to
Everything worked just fine.
Thanks.