} $quoteImg = $newMedia; break; default: $quoteObj->{$postVar} = filter_input(INPUT_POST, $postVar) ? mysqli_real_escape_string($dbObj->connection, filter_input(INPUT_POST, $postVar)) : ''; if ($quoteObj->{$postVar} === "") { array_push($errorArr, "Please enter {$postVar} "); } break; } } if (count($errorArr) < 1) { $target_file = MEDIA_FILES_PATH . "quote/" . $quoteImg; $uploadOk = 1; $msg = ''; if ($newMedia != "") { move_uploaded_file($_FILES["image"]["tmp_name"], $target_file); } if ($oldMedia != '' && file_exists(MEDIA_FILES_PATH . "quote/" . $oldMedia)) { unlink(MEDIA_FILES_PATH . "quote/" . $oldMedia); } echo $quoteObj->update(); } else { $json = array("status" => 0, "msg" => $errorArr); $dbObj->close(); //Close Database Connection header('Content-type: application/json'); echo json_encode($json); } } }