Hi.

I am new to PHP and would like to have the support from the members of this forum to learn PHP in depth.

Here is my 1st question/post to this forum and expecting the solution from this forum.

I want to read a MS Word doc file and even modify the same using PHP. In my case, PHP is installed on unix server and also I have uploaded the ".doc" file to be read & modified on the same unix server. So please let me know the code to read & modify the same.

Thanks in advance.

Hi Uma_fb and welcome to DaniWeb :)

I have never tried to do this with a .doc file, but I'm guessing it is the same as opening/modifying a text file. Let me point you to the PHP Manual, http://au.php.net/ that has lots of great documentation on the php language including user examples. Some functions that you will need to achieve your task are:

fopen -> opens a file
fread -> reads data from a file
fwrite -> yep you guessed it, this one writes to a file :)

Anyway, there's a few pointers. Have a play and see what you can come up with. If you get stuck, post your coding attempt or ask some specific questions and we will try to guide you.

Good luck :)
darkagn

Thanks for your suggestions.

I tried the sequence of fopen, fread and displaying the contents. This displays the contents of doc file but not in the format. Its just continuous lines with some binary like characters in the start and end of the display.

Here are the lines which I tried with

<<<
$fp = fopen("test.doc", "rb");

$contents_doc = fread($fp, filesize("test.doc"));
fclose($fp);
echo $contents_doc;
>>>

Please let me know what to add more to the above to get the contents in the format. OR Please suggest any other way to achieve the same.

how to read doc file using php if any body know please help me , this is very urgent for me
or how convert doc file to txt file

Please Guide Me on How to read and display a doc and pdf file using php in unix i have tried the following code but cannot display contents except the binary format plz guide me on it $handle = fopen($filename, "rb");
$contents = fread($handle, filesize($filename));

Edited 6 Years Ago by prasadk123: n/a

This article has been dead for over six months. Start a new discussion instead.