I am not getting what i want,
Here is My Code :
if (isset($_FILES["avatar"]["name"]) && $_FILES["avatar"]["tmp_name"] != "") { /* Main IF statement starts Here */
$fileName = $_FILES["avatar"]["name"];
$fileTmpLoc = $_FILES["avatar"]["tmp_name"];
$fileType = $_FILES["avatar"]["type"];
$fileSize = $_FILES["avatar"]["size"];
$fileErrorMsg = $_FILES["avatar"]["error"];
$kaboom = explode(".", $fileName);
$fileExt = end($kaboom);
list ($width, $height) = getimagesize($fileTmpLoc);
if ($width < 10 || $height < 10) {
header("Location: a.php?err=2");
exit();
}
$db_file_name = rand(100000000000, 999999999999) . "." . $fileExt;
if ($fileSize > 1048576) {
header("Location: a.php?err=3");
exit();
}
elseif (! preg_match("/\.(gif|jpg|png)$/i", $fileName)) {
header("Location: a.php?err=4");
exit();
}
elseif ($fileErrorMsg == 1) {
header("Location: a.php?err5");
exit();
}
} /* Main IF statement ends Here */
else {
header("Location: go_back.php?err=2");
exit();
}
Width and height validations are working properly, but if ($fileSize > 1048576)
filesize is greater than 1MB then it redirects me to go_back.php?err=2
and I want it to redirect to a.php?err=3