$image = $_FILES['image']['name'];
$imageFlag = true;
if (empty($image)) {
$imageFlag = false;
} else {
$file_extension = strtolower(pathinfo($_FILES["image"]["name"], PATHINFO_EXTENSION));
$allowed_image_extension = array(
"jpeg",
"png",
"jpg"
);
$fileinfo = @getimagesize($_FILES["image"]["tmp_name"]);
$width = $fileinfo[0];
$height = $fileinfo[1];
if ($width > 1500 || $height > 1600 || $width > $height) {
$output['error']['image'] = "* image dimensions should be less than 400*500 and width should be less than height i.e passport size image";
$imageFlag = false;
}
if (!in_array($file_extension, $allowed_image_extension)) {
$imageFlag = false;
$output['error']['image'] = "Only jpg , jpeg and png format are allowed";
}
if (($_FILES["image"]["size"] > 20000000)) {
$imageFlag = false;
$output['error']['image']= "Image size should be less than 2mb";
}
if ($imageFlag) {
$imageName = time() . 'Teacher.' . $file_extension;
$target = ("images/teacher/" . basename($imageName));
$m = move_uploaded_file($_FILES['image']['tmp_name'], $target);
}
}