In this tutorial I’m going to show you how to read .doc files in php. Doc files are files that are made using Microsoft Word if you’re on Windows. And Open Office if you’re on Linux.
First you have to extract the contents of the zip archive into your project folder. Rename the extracted folder to antiword if it isn’t already named antiword.
From the antiword folder, copy the file named 8859-1.txt and paste it on:
Just create an antiword folder directly under c: drive or where Windows is installed if its not created yet.
Next, just paste in the code below, and edit it to match your configuration. Note that tuts.doc in the example below is adjacent to the php script. But you can also change that if you want a separate folder for doc files alone. The –f parameter will just format the output. It will wrap words that are bold with * * and italics with / /. I’m still yet to figure out how to convert those into actual html.
<?php $filename = 'tuts.doc'; $content = shell_exec('C:wampwwwtesterread_documentsantiwordantiword -f '.
$filename); echo $content; ?>
I won’t put any conclusion on this tutorial. I really think its incomplete. So if ever you know how to format the result of the script then please shout them out in the comments below.