Saturday, September 12, 2015

PHP convert doc file to text file

PHP allows file uploads, file write, copy, move, delete and also it supports conversion of one file format to another.
In this example we will see how a doc file is converted to a text file.

function doc2text($file)
{
$file     = $directory.'/'.$filename;
$fileinfo = pathinfo($filename);
$content  = "";
// doc to text
$content = shell_exec("antiword -m UTF-8.txt -t $file");
return $content;
}

 The usage of the function is as follows:

  $file = "documents/files/doc/test.doc";
  doc2text($file);

No comments:

Post a Comment

MS SQL : How to identify fragmentation in your indexes?

Almost all of us know what fragmentation in SQL indexes are and how it can affect the performance. For those who are new Index fragmentation...