Page 1 of 1

[56K WARN] display a word document in a textarea using PHP

Posted: Fri Jun 22, 2007 4:47 am
by dream2rule
Hello All,

I would like to know whether is it possible to display a word document in a textarea using PHP.

Regads

Posted: Fri Jun 22, 2007 4:53 am
by Styx
Try looking up how to use the COM class.

Posted: Fri Jun 22, 2007 4:56 am
by dream2rule
hie styx.. but i have no idea about COM classes..

Can't i do it using simple PHP without OOPS principles?

Posted: Fri Jun 22, 2007 5:01 am
by dream2rule
To be more specific...

Image

I am uploading a word file and storing it in a folder in the project directory.

Now, I have the path to the word file which was uploaded.

I am trying to open that file and reading its contents and displaying it in the textarea.

But in the textarea.. along with the file contents, even the properties of that word file are being displayed.

Image

I want to know is there anyway i can display only he contents of the word file in the textarea leaving aside the properties of the word file.

Thanks and Regards

Posted: Fri Jun 22, 2007 6:43 am
by feyd
Unfortunately, Word documents are binary files, not simple text. You will have to parse them, whether you like it or not. I'd suggest switching to a more straight forward document format, be it XML, RTF, or plain text.

Posted: Fri Jun 22, 2007 7:15 am
by djot
US link to COM class from above does not work, try this one instead:
http://www.php.net/manual/en/ref.com.php

Posted: Mon Jun 25, 2007 3:44 am
by dream2rule
feyd wrote:Unfortunately, Word documents are binary files, not simple text. You will have to parse them, whether you like it or not. I'd suggest switching to a more straight forward document format, be it XML, RTF, or plain text.
hie feyd..

But the point is.. i am uploading a resume of the user which is generally in a .doc format.

How do i get only the entire details of his resume but not the properties of the word document!

Regards,

Posted: Mon Jun 25, 2007 4:53 am
by onion2k
dream2rule wrote:How do i get only the entire details of his resume but not the properties of the word document!
Basically you can't. While it's possible using the COM interface to MS Word the chance of that working on a live production server are close to zero. You'd have to put Word on the server. Writing a parser that works with every version of the .doc format would be years of work.

My advice... rethink. Why do you need to display the file contents in a text area? What are you doing with the content?

Also, somewhat off topic, if you're in the UK your form there is going to be breaking the law. Asking someone how much experience they have violates the new Employment Equality (Age) Regulations 2006 act.