if ($docFileType != 'doc' && $docFileType != 'docx' && $docFileType != 'pdf' && $docFileType != 'xls' && $docFileType != 'csv') { $msg .= "Brochure must be in either of these formats: PDF, DOC, DOCX, XLS, CSV."; $uploadOk = 0; } if ($uploadOk == 0) { $msg = "Sorry, your course brochure document was not uploaded. ERROR: " . $msg; $json = array("status" => 0, "msg" => $msg); $dbObj->close(); //Close Database Connection header('Content-type: application/json'); echo json_encode($json); } else { if (move_uploaded_file($_FILES["document"]["tmp_name"], MEDIA_FILES_PATH . "/brochure/" . $coursBrochDoc)) { $msg .= "The file " . basename($_FILES["document"]["name"]) . " has been uploaded."; $status = 'ok'; echo $coursBrochObj->add(); } else { $msg = " Sorry, there was an error uploading your course brochure document. 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);