How to Read a DOC File Using PHP
Things You'll Need
Instructions
1Verify with your host provider that PHP access is available for your website. Most servers support PHP, but occasionally this service requires an account upgrade. You cannot read a DOC file using PHP without access to the compiler.
2
Download the Antiword MS Word document reader utility (see References). This open-source program contains programming materials that extend PHP for DOC conversion.
3
Unzip the Antiword archive to extract its contents.
4
Upload the entire Antiword file library to the web server. Place the files in the "bin" directory of the host account. This directory is a common repository for utilities and other binary operations that web server users must frequently exploit.
5
Call the Antiword program in any PHP script designed to read a DOC Microsoft Word document. The command is implemented using a single function. Type "$content = shell_exec('/usr/local/bin/antiword '.$filename);" where "$filename" equals the full file name of the DOC document. The contents of the DOC file will be read into the variable "$content". These variable names, beginning with the "$" symbol, are customizable.
6
Process the "$content" variable as desired to manipulate the contents of the DOC file. Once the DOC is read by PHP, the full text of the file is available for any form of further activity. The contents can be emailed or stored to a database, for example.
Source...