doc2txt php script

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
nokiamobileAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
cammjConnect With a Mentor Commented:
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
All Courses

From novice to tech pro — start learning today.