0
$myFile = "pdf/document_file.doc";
$fh = fopen($myFile, 'r');
$theData = file_get_contents($myFile);
fclose($fh);
echo "<pre>";
echo $theData;
echo "</pre>";

My above script fetches the data from document file but it display some of binary numbers.

I need to display document file content in to html content

For Example If my document file is a resume. i need to fetch the content and display document data same as selected file in html page

Mohan Ram
  • 8,345
  • 25
  • 81
  • 130

2 Answers2

1

It IS binary data. To view it as HTML you need to convert it first.

Convert .doc to html in php

Community
  • 1
  • 1
Tadas Šubonis
  • 1,570
  • 2
  • 16
  • 21
1

You're reading binary data. Hence the "numbers". The raw data needs to go through some "filter/render implementation" first.

Plus, when you use file_get_contents() there's no need to fopen() and fclose().

Linus Kleen
  • 33,871
  • 11
  • 91
  • 99