Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

doc2txt php script

Posted on 2008-10-02
1
1,345 Views
Last Modified: 2012-05-05
Hi,
could you provide me a php script that convert a doc document loaded in a variable ($document) to txt?
I don't need to maintain the format.

thanks
0
Comment
Question by:nokiamobile
1 Comment
 
LVL 5

Accepted Solution

by:
cammj earned 500 total points
ID: 22631489
It's not possible to directly read doc files if they were created using Microsoft Word, because the files are stored in a binary format that PHP cannot understand.

It is possible to leverage Microsoft Word to do the reading of the files though, but this requires that the OS you are running your php scripts on is a Windows machine and also has access to a copy of Microsoft Word.

This can be done with something like this

$filehandler = new COM("word.application");
$filehandler->Documents->Open(realpath("pathtomydocument.doc"));
$file = (string) $filehandler->ActiveDocument->Content;

echo $file;

$filehandler->ActiveDocument->Close(false);
$filehandler->Quit();
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question