0

I uploaded the .doc file using php code and saved it in a folder ,the path is stored in database.

When i tried to make a view of the doc file in a div ...a dialog box appears asking whether to save or openwith ..

I'm using wampserver ....I just tried like this

<iframe name="awindow" frameborder=2 width=580 height=440 src="www/siva_example/pdf/1_siva.doc"></iframe>

Any help regarding.. Is it possible to view .doc file in browser or i have to convert it to pdf format...

klenium
  • 2,468
  • 2
  • 24
  • 47
siva s
  • 3
  • 1
  • 4
  • You can't display a doc file within the html, unless you decode the file, convert it to html, with a php decoder, like [PHPWord](http://phpword.codeplex.com/). – klenium Jul 25 '15 at 11:02

3 Answers3

1

It's not possible to display a .doc[x] in HTML. You can try to convert the .doc[x] to HTML or to an image.

luklapp
  • 205
  • 1
  • 3
  • 13
0

you can view doc file by adding this to your header at request time

<?php
header('Content-disposition: inline');
header('Content-type: application/msword'); 
// not sure if this is the correct MIME type
readfile('MyWordDocument.doc');
exit;
  • it should work. if not. try these same question solution over http://stackoverflow.com/questions/4346117/how-can-i-view-open-a-word-document-in-my-browser-using-with-php-or-html –  Jul 25 '15 at 11:12
  • I hope you read the comment below the answer mentioned.."This isn't guaranteed to work though; " – siva s Jul 25 '15 at 11:20
0

You could try using google docs for this, use the below code, it works perfectly for ppts, have not been able to test it for a doc yet

<iframe src="http://docs.google.com/gview?url=http://yourdomain.com/document.doc&embedded=true" style="width:550px; height:450px;" frameborder="0"></iframe>

Ofcourse you would have to update the url as per your program using PHP

TDsouza
  • 910
  • 2
  • 13
  • 38
  • no - it has to be a publicly accessible URL for this to work. It also has limitations - for even semi-popular sites its easy to run into rate limits, and get an error. – sevenseacat Jul 25 '15 at 14:20
  • agreed with @sevenseacat btw why would you need this to work on localhost... just a little curious – TDsouza Jul 26 '15 at 12:42