<?php require_once "../framework.php"; //if it needs to include some php file then include if (!isset($_SERVER["REQUEST_METHOD"]) || $_SERVER["REQUEST_METHOD"] != "POST") { header("HTTP/1.1 400 Invalid Request"); die("ERROR 400: Invalid request - This service accepts only POST requests."); } header("Content-type: application/xml"); $dom_xml = new DOMDocument(); $resultset = $dom_xml->createElement("resultset"); $dom_xml->appendChild($resultset); $db = new LectureNote(); if (isset($_REQUEST["course"]) && $_REQUEST["course"] != null && isset($_REQUEST["lecture"]) && $_REQUEST["lecture"] != null && isset($_REQUEST["page"]) && $_REQUEST["page"] != null) { $result = $db->writeQuestion($_REQUEST["course"], $_REQUEST["lecture"], $_REQUEST["content"], $_REQUEST["page"], $_REQUEST["posX"], $_REQUEST["posY"]); if ($result instanceof Exception) { $result_tag = $dom_xml->createElement("result"); $result_tag->appendChild($dom_xml->createTextNode("SQLException")); $resultset->appendChild($result_tag); } else { $result_tag = $dom_xml->createElement("result"); $result_tag->appendChild($dom_xml->createTextNode("success")); $resultset->appendChild($result_tag); } } else { $result_tag = $dom_xml->createElement("result"); $result_tag->appendChild($dom_xml->createTextNode("ValidationError")); $resultset->appendChild($result_tag); } print $dom_xml->saveXML();
<?php require_once "../framework.php"; //if it needs to include some php file then include if (!isset($_SERVER["REQUEST_METHOD"]) || $_SERVER["REQUEST_METHOD"] != "POST") { header("HTTP/1.1 400 Invalid Request"); die("ERROR 400: Invalid request - This service accepts only POST requests."); } header("Content-type: application/xml"); $dom_xml = new DOMDocument(); $resultset = $dom_xml->createElement("resultset"); $dom_xml->appendChild($resultset); $db = new LectureNote(); if (isset($_REQUEST["course"]) && $_REQUEST["course"] != null && isset($_REQUEST["lecture"]) && $_REQUEST["lecture"] != null && isset($_REQUEST["page"]) && $_REQUEST["page"] != null) { $result = $db->writeQuestion($_REQUEST["question_id"], $_REQUEST["content"]); if ($result instanceof Exception) { $result_tag = $dom_xml->createElement("result"); $result_tag->appendChild($dom_xml->createTextNode("SQLException")); $resultset->appendChild($result_tag); } else { $result_tag = $dom_xml->createElement("result"); $result_tag->appendChild($dom_xml->createTextNode("success")); $resultset->appendChild($result_tag); } } else { $result_tag = $dom_xml->createElement("result"); $result_tag->appendChild($dom_xml->createTextNode("ValidationError")); $resultset->appendChild($result_tag); } print $dom_xml->saveXML();
function loadimage() { //print header('Content-Type: image/jpeg'); //print json_encode("hello"); $db = new LectureNote(); $result = $db->getImage($_POST['lecturecourse'], $_POST['lecturenumber'], $_POST['page']); $filename = $result['filename']; //print($img); # 이미지 실제경로 그리고 이미지 이름 //$url = "img/new/" . $_GET[img_name] .".jpg"; print json_encode($filename); }
//round(microtime(true)) . '.' . end($temp);//// //filename $uploadOk = 1; $imageFileType = strtolower($temp[1]); // Check if file already exists // Check file size if ($_FILES["file_name"]["size"] > 50000000000) { // echo "Sorry, your file is too large."; $uploadOk = 0; } // Allow certain file formats if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif" && $imageFileType != "pdf") { // echo "Sorry, only JPG, JPEG, PNG , GIF & PDF files are allowed."; $uploadOk = 0; } // Check if $uploadOk is set to 0 by an error if ($uploadOk == 0) { // echo "Sorry, your file was not uploaded."; // if everything is ok, try to upload file } else { if (move_uploaded_file($_FILES["file_name"]["tmp_name"], $target_dir . $newfilename)) { $upload_result = "SUCCESS"; //echo "The file ". basename( $_FILES["file_name"]["name"]). " has been uploaded."; } } $db = new LectureNote(); $c_id = $db->getCourseId($_POST["lecturecourse"]); $result = $db->insertPage($c_id, $_POST["lecturenumber"], $_POST["input_page"], $newfilename); } ?>