我正在尝试将word文档转换为文本,并使用以下代码:
public function executeManoj() {
$filename='C:xampphtdocsbranch.comwebgreenwich-beer-and-jazz-application-form.doc';
$TXTfilename = $filename . ".txt";
$word = new COM("word.application") or die("Unable to instantiate Word object");
$word->Documents->Open($filename);
// the '2' parameter specifies saving in txt format
$word->Documents[1]->SaveAs($TXTfilename ,2);
$word->Documents[1]->Close(false);
$word->Quit();
$word->Release();
$word = NULL;
unset($word);
$content = file_get_contents($TXTfilename);
//unlink($TXTfilename);
exit;
}
但这会导致错误地说
"无法创建 COM 对象'word.application':语法无效"....
我已经在 xammp 中设置了"允许服务与桌面交互"。
我是否需要在它之前安装任何软件?
关于这个PHP错误,似乎您的计算机上没有安装word.application
。尝试先安装它(不知道在哪里可以找到它...