Jump to content

Recommended Posts

the method i use is very similar to what jitesh mentions. without knowing the exact file format's structure, it's very hit and miss - if it's important to keep the formatting in tact, then you're going to struggle a bit unless you're prepared to get down and dirty and do some serious homework.

 

in addition to jitesh's code, put this line:

 

$header = fread($handle, 2560);

 

just before the $contents = fread() line, which will read off the first 2560 bytes (which is essentially the header and useless without knowing what to do with it...)

 

what you're left with then (in $contents) is the plain text with various formatting characters (ie, the 'Junk' you mention). a series of str_replace / preg_replace will deal with these.

 

there are programs such as antiword / catdoc, etc you can google for (both free) which will take the headache out of it, but like i say - if you want it to appear in your browser as it would in MS Word itself, then you'd need a plugin for your browser, rather than anything specifically PHP

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.