$xmlcontents = XMLReader::open($_FILES["gps"]["tmp_name"]);
$xmlcontents->setParserProperty(XMLReader::VALIDATE, true);
if($xmlcontents->isValid() and ($xml->xml($_FILES["gps"]["tmp_name"], NULL, LIBXML_DTDVALID))) {
}
else {
echo 'Not a valid GPS file!")';
exit();
}
note here you check the file validity as xml , and it's extention try this