clearstatcache();
if($_FILES['images']){
if ($_FILES['images']['error'] !== UPLOAD_ERR_OK) {
$error[] = "Upload failed with error code " . $_FILES['images']['error'];
}
$info = getimagesize($_FILES['images']['tmp_name']);
if ($info === FALSE) {
$error[] = "Unable to determine image type of uploaded file";
}
if (($info[2] !== IMAGETYPE_GIF) && ($info[2] !== IMAGETYPE_JPEG) && ($info[2] !== IMAGETYPE_PNG)) {
$error[] = "Not a gif/jpeg/png";
}
if ($_FILES["images"]["size"] > 100000) {//1mb limit
$error[] = "Sorry, your file is too large.";
}
}
this is my php code. checking if the file is empty. and i want. if the file is exist then php will check the file image. but if the user did not choose a image. the validation will just ignor it. i cant debug it. if im not picking an image the code still validation and error said Warning: getimagesize(): Filename cannot be empty in C:\xampp\htdocs\savings\LiveUpdate.php on line 10