There was a problem with PHP reading the doc file.
Baidu installed third-party package to achieve
System Hint * * is not a Word document ....
Help
Reply content:
There was a problem with PHP reading the doc file.
Baidu installed third-party package to achieve
System Hint * * is not a Word document ....
Help
You can use Phpword to make sure that your PHP version is PHP 5.3+
if ($ext = = ' docx ') {
docx files can be read directly
$contents = $this->extracttext ($file);
}elseif ($ext = = ' Doc ') {
Doc file, you need to install Antiword software to read
$contents = Shell_exec ("antiword-m UTF-8 $file");
}else{
$contents = file_get_contents ($file);
}
function extracttext($filename) { $ext = end(explode('.', $filename)); if($ext == 'docx') $dataFile = "word/document.xml"; else $dataFile = "content.xml"; $zip = new ZipArchive; if (true === $zip->open($filename)) { if (($index = $zip->locateName($dataFile)) !== false) { $text = $zip->getFromIndex($index); $xml = DOMDocument::loadXML($text, LIBXML_NOENT | LIBXML_XINCLUDE | LIBXML_NOERROR | LIBXML_NOWARNING); return strip_tags($xml->saveXML()); } $zip->close(); } return false;}