$uploadOk = 0; } if ($imageFileType != "jpg" && $imageFileType != "jpeg" && $imageFileType != "png" && $imageFileType != "gif" && $imageFileType != "bmp") { $msg .= "Sorry, only image files are allowed."; $uploadOk = 0; } if ($uploadOk == 0) { $msg = "Sorry, your tutor picture was not uploaded. ERROR: " . $msg; $json = array("status" => 0, "msg" => $msg); header('Content-type: application/json'); echo json_encode($json); } else { if (move_uploaded_file($_FILES["picture"]["tmp_name"], $targetFile)) { $msg .= "The picture has been uploaded."; $status = 'ok'; echo $tutorObj->add(); } else { $msg = " Sorry, there was an error uploading your tutor picture. ERROR: " . $msg; $json = array("status" => 0, "msg" => $msg); $dbObj->close(); //Close Database Connection header('Content-type: application/json'); echo json_encode($json); } } } else { $json = array("status" => 0, "msg" => $errorArr); $dbObj->close(); //Close Database Connection header('Content-type: application/json'); echo json_encode($json);