Read Word Document Using PHP

by satheeshkumar 2013-08-07 11:03:19

Read Word Document Using PHP,

To read and display the word document using PHP,use the following code..


<?php

$filename = "Your file name";
if ( file_exists($filename) ) {
if ( ($fh = fopen($filename, 'r')) !== false ) {

$headers = fread($fh, 0xA00);
$n1 = ( ord($headers[0x21C]) - 1 );
$n2 = ( ( ord($headers[0x21D]) - 8 ) * 256 );
$n3 = ( ( ord($headers[0x21E]) * 256 ) * 256 );
$n4 = ( ( ( ord($headers[0x21F]) * 256 ) * 256 ) * 256 );
$textlength = ($n1 + $n2 + $n3 + $n4);
$fileContent = fread($fh, $textlength);
$fileContent = nl2br($fileContent);
echo $fileContent;
}
}

?>

Tagged in:

920
like
0
dislike
0
mail
flag

You must LOGIN to add comments