You might even think about. Is PHP able to load Doc files.
The answer …. it could.
Maybe you’ve done it using the following script:
file_get_contents($filename);
The above code will run smoothly for the file type plain text. However, it will be a problem if we file type is a word document.
If we only use the above code to load a Doc file, then all the tags that should not be displayed, will be displayed. Thus, it would appear chaotic. Texts so that we do not want do not come then we have to convert first. How do I …?
The problem above can be overcome with the following script snippet:
function parseWord($filename) {
$fileHandle = fopen($filename, "r");
$line = @fread($fileHandle, filesize($userDoc));
$lines = explode(chr(0x0D),$line);
$outtext = "";
foreach($lines as $thisline)
{
$pos = strpos($thisline, chr(0x00));
if (($pos !== FALSE)||(strlen($thisline)==0)){
} else {
$outtext .= $thisline." ";
}
}
$outtext = preg_replace("/[^a-zA-Z0-9\s\,\.\-\n\r\t@\/\_\(\)]/","",$outtext);
return $outtext;
}$text = parseWord($filename);
Maybe there are some words that do not want that still appears. But at least, this can be a little help you.
Good luck … and develop more
Incoming search terms for the article:
No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.






mantabs
I tried the code but it doesn’t display any output.
Do you have successfully loaded the document files?
Try again the script above
variable $filename is a variable that contains the file content (input)
variable $text is the variable that contains the output
To display the output, you can use a script like this:
nice one, thanks a lot
thanks, just what i was looking for!
Will continue to read it as I’m very new to a lot of the points you mention! Thanks though, I’m glad some people share good stuff like this!
Thanks mate, that is a good post.
Excellent post, thanks!
Excellent post, thanks for the helpful info!
I’m using like follow the code but not working for me, i’m writing this in a php and including another file..
not working ……. wht is my prob??????????///
May I know What output did you get?
You are welcome
Nice article.. I am going to bookmark your web site and keep checking you out. Thanks for sharing your blog.
thanks for bookmark
hey thanks for nice tutorial i used in my download free full games site .
Thanks for nice article and great tips keep doing