0

Hello Every one is there any body who could help me on
how to open a doc file and how to read its content

thanks in advance

3
Contributors
17
Replies
18
Views
8 Years
Discussion Span
Last Post by manishmannan
0

Hello Every one is there any body who could help me on
how to open a doc file and how to read its content

thanks in advance

The simplest way to do it -

$handle = fopen("file_name.doc", "rb");
$contents = '';
while (!feof($handle)) {
  $contents .= fread($handle, 8192);
}
fclose($handle);
0

how to print those content those hav been read

In above example all the file content came inside the "$contents". you can simply echo it, to display the contents at once like -

echo  $contents;
0

and i want to knw one more thing is how to dycrpt ms word file plz tell me??

0

and i want to knw one more thing is how to dycrpt ms word file plz tell me??

Be clear what you want to achieve.
Are you looking to decypt the file encrypted already

0

yes ,you have pasted the code for me its read the content in binary format and whenever i am printing the content with echo command
it print in binary format
now i need to have a code to display the content in our font like we used in all aplication

0

yes ,you have pasted the code for me its read the content in binary format and whenever i am printing the content with echo command
it print in binary format
now i need to have a code to display the content in our font like we used in all aplication

just play around with the code ,while reading the contents from the file.
search for 'file_get_contents ()' online.

0

whenever i print my doc file content it print like this
.0-[ bjbj .ΐΐ 0:<<<<<<$N``u::ۭb &0$`` : sgsgfsgdfgdfgdfg hXh ,1h/ =!"#$% f 666666666vvvvvvvvv666666>6666666666666666666666666666666666666666666666666hH6666666666666666666666666666666666666666666666666666666666666666662 0@P`p2( 0@P`p 0@P`p 0@P`p 0@P`p 0@P`p 0@P`p8XV~OJQJ_HmH nH sH tH J`J Normal dCJ_HaJmH sH tH DA D Default Paragraph FontRiR 0 Table Normal4 l4a (k ( 0No List PK![Content_Types].xmlj0Eжr(΢Iw},-j4 wP-t#bΙ{UTU^hd}㨫)*1P' ^W0)T9<l#$yi};~@(Hu* Dנz/0ǰ $ X3aZ,D0j~3߶b~i>3\`?/[G\!-Rk.sԻ..a濭?PK!֧6 _rels/.relsj0 }Q%v/C/}(h"O = C?hv=Ʌ%[xp{۵_Pѣ<1H0ORBdJE4b$q_6LR7`0̞O,En7Lib/SeеPK!kytheme/theme/themeManager.xml M @}w7c(EbˮC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K] 8@0( B S ? bLX@8`@UnknownG* Times New Roman5Symbol3. * Arial7.{ @CalibriACambria Math"1h:\f:\f!r02HX $P 2!xx CHANGE_ME CHANGE_MEOh+'0p , 8 DPX`h CHANGE_MENormal CHANGE_ME2Microsoft Office Word@@b@b՜.+,0 hp NONE Title !"#$&'()*+,/Root Entry F8b1Data 1TableWordDocumentSummaryInformation(DocumentSummaryInformation8%CompObjy F'Microsoft Office Word 97-2003 Document MSWordDocWord.Document.89q

0

whenever i print my doc file content it print like this
.0-[ bjbj .ΐΐ 0:<<<<<<$N``u::ۭb &0$`` : sgsgfsgdfgdfgdfg hXh ,1h/ =!"#$% f 666666666vvvvvvvvv666666>6666666666666666666666666666666666666666666666666hH6666666666666666666666666666666666666666666666666666666666666666662 0@P`p2( 0@P`p 0@P`p 0@P`p 0@P`p 0@P`p 0@P`p8XV~OJQJ_HmH nH sH tH J`J Normal dCJ_HaJmH sH tH DA D Default Paragraph FontRiR 0 Table Normal4 l4a (k ( 0No List PK![Content_Types].xmlj0Eжr(΢Iw},-j4 wP-t#bΙ{UTU^hd}㨫)*1P' ^W0)T9<l#$yi};~@(Hu* Dנz/0ǰ $ X3aZ,D0j~3߶b~i>3\`?/[G\!-Rk.sԻ..a濭?PK!֧6 _rels/.relsj0 }Q%v/C/}(h"O = C?hv=Ʌ%[xp{۵_Pѣ<1H0ORBdJE4b$q_6LR7`0̞O,En7Lib/SeеPK!kytheme/theme/themeManager.xml M @}w7c(EbˮCAǠҟ7՛K Y, e.|,H,lxɴIsQ}#Ր ֵ+!,^$j=GW)E+& 8PK!Ptheme/theme/theme1.xmlYOo6w toc'vuر-MniP@I}úama[إ4:lЯGRX^6؊>$ !)O^rC$y@/yH*

0

To open doc file i am using this
$resume = $rows;
$filename = "$resume";
$fp = fopen($filename, "r") or die("Can't open file");
$file_contents = file_get_contents($filename);
echo $file_contents;
fclose($fp);

0

To open doc file i am using this
$resume = $rows;
$filename = "$resume";
$fp = fopen($filename, "r") or die("Can't open file");
$file_contents = file_get_contents($filename);
echo $file_contents;
fclose($fp);

can you try with this code-

<?php
$filename = "your_doc.doc";
 
// Make sure the file is valid
if(!file_exists($filename) ) {
    die("The file '{$filename}' does not exist.");
}
if(filesize($filename) == 0) {
    die("The file is empty.");
}
header("Content-Type; application/msword");
header("Content-Disposition: attachment; filename=". basename($filename));
header("Content-Length: ". filesize($filename));
header("Content-Transfer-Encoding: binary");

readfile($filename);
?>
0

The above code will ask to download the doc file and this one more to directly read the contents in the browser -

//For Linux
//$char = 0x0A;
//0x00 Stands for NO Operation
function parseWord($userDoc) 
{
    $fileHandle = fopen($userDoc, "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);
     $outtext = preg_replace("/[^a-zA-Z0-9\s\,\.\-\n\r\t@\/\_\(\)]/","",$outtext);

    return $outtext;
} 

$userDoc = "test.doc";

$text = parseWord($userDoc);
echo $text;

But I am sure it will work for windows machine only.You will need to change chr() string in the explode on Linux machine to get it working maybe.

0

thanks network i am able read the content of a file but there is some problem like i need to display the resume like in monester india.com where we can see our resume in same format as we have in doc do u have some idea how to do this sry for late replying

0

thanks network i am able read the content of a file but there is some problem like i need to display the resume like in monester india.com where we can see our resume in same format as we have in doc do u have some idea how to do this sry for late replying

It is even more simple , you just need the code like this -

<iframe id="myFrame" style="display:none" width="500" height="300"></iframe>
<input type="button" value="Open PDF" onclick = "openPdf()"/>
<script type="text/javascript">
function openPdf()
{
var omyFrame = document.getElementById("myFrame");
omyFrame.style.display="block";
omyFrame.src = "yourFile.pdf";
}
</script>
0

hii network i am able to get your all help sucessfully thanks alot network now i closing this thread

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.