validating uploaded XML
Posted: Thu Feb 05, 2004 4:29 pm
I am using the upload script to below to upload an XML file. Before processing, I would like to check that the XML document is well formed by validating it against a XML schema.
How can I acheive this please?
How can I acheive this please?
Code: Select all
<?php
if ($HTTP_POST_FILES['userfile']['name']=="none") {
echo "Problem: no file uploaded";
exit;
}
if ($HTTP_POST_FILES['userfile']['size']==0){
echo "Problem: uploaded file is zero length";
exit;
}
if ($HTTP_POST_FILES['userfile']['type'] != "text/xml") {
echo "Problem: file is not an xml file";
exit;
}
if (!is_uploaded_file($_FILES['userfile']['tmp_name'])) {
echo "Problem: possible file upload attack";
exit;
}
$uploaddir = "uploads/";
$upfile = $uploaddir. $_FILES['userfile']['name'];
if (!move_uploaded_file($_FILES['userfile']['tmp_name'], $upfile)) {
echo "Problem: Could not move file into directory";
exit;
}
?>