使用php以读取模式打开Word文档?
我想用PHP在浏览器中阅读Word文档。 我已经试了两个多小时了,但还是没能成功。使用php以读取模式打开Word文档?,php,Php,我想用PHP在浏览器中阅读Word文档。 我已经试了两个多小时了,但还是没能成功。 有人能帮我做这件事吗?由于您的问题中没有太详细的说明您的具体要求或服务器设置,这将帮助您开始并回答问题 <?php $DocumentPath="C:/xampp/htdocs/test.doc"; //Create an instance of the Word application $word = new COM("word.application") or die("Unable to instan
有人能帮我做这件事吗?由于您的问题中没有太详细的说明您的具体要求或服务器设置,这将帮助您开始并回答问题
<?php
$DocumentPath="C:/xampp/htdocs/test.doc";
//Create an instance of the Word application
$word = new COM("word.application") or die("Unable to instantiate application object");
//Creating an instance of the Word Document object
$wordDocument = new COM("word.document") or die("Unable to instantiate document object");
$word->Visible = 0;
//Open up an empty document
$wordDocument = $word->Documents->Open($DocumentPath);
//Create the filename for the HTML version
$HTMLPath = substr_replace($DocumentPath, 'html', -3, 3);
//Save the document as HTML
$wordDocument->SaveAs($HTMLPath, 3);
// clean up
$wordDocument = null;
$word->Quit();
$word = null;
// read the newly-created document
readfile($HTMLPath);
//delete the file
unlink($HTMLPath)
?>
word文档在您的服务器上是否正确?这是*nix还是Windows环境?