Exemplo n.º 1
0
                $file = $_POST['uploadfile'];
                if (substr($file, -4) == ".txt") {
                    $myfile = fopen($file, "r") or die("Unable to open file!");
                    $advice = fread($myfile, filesize("{$file}"));
                    fclose($myfile);
                }
            }
            $res = ConsultService::advice($id, $advice);
            header("Location: http://localhost/healthyone/view/consultManage.php?");
        }
        if ($_GET['operation'] == 2) {
            if (isset($_POST['uploadfile'])) {
                $file = $_POST['uploadfile'];
                if (substr($file, -4) == ".xml") {
                    $doc = new DOMDocument();
                    $doc->load($file);
                    $advices = $doc->getElementsByTagName("advice");
                    foreach ($advices as $advice) {
                        $users = $advice->getElementsByTagName("user");
                        $user = $users->item(0)->nodeValue;
                        $contents = $advice->getElementsByTagName("content");
                        $content = $contents->item(0)->nodeValue;
                        echo $user;
                        $res = ConsultService::advice($user, $content);
                    }
                    header("Location: http://localhost/healthyone/view/consultManage.php");
                }
            }
        }
    }
}