Word file to Text File Converter
I am trying to convert a word file in to text file by the following code :
function wordToText($wordDocPath,$textFilePath)
{ $word = new COM("word.application") or die("Unable to instanciate Word");
$word->Visible = 0;
$word->Documents->Open($wordDocPath);
$numParagraphs = $word->ActiveDocument->Paragraphs->Count;
$paraString = '';
for($i = 1; $i <= $numParagraphs; $i++)
{
$paraString .= $word->ActiveDocument->Paragraphs[$i];
}
$word->Quit();
$handle = fopen($textFilePath, 'w');
fwrite($handle, $paraString);
fclose($handle);
}
wordToText('d:\test\test1.doc', 'docdump.txt');
print 'Conversion Complete.';
If I run this code in localhost it is working but, when I upload this file in to server the folloowing error is coming :
Fatal error: Class 'COM' not found in /home/destiny/public_html/weblink/word.php on line 4
|