It depends on what you want to do. You can pass the request to the system (only works for specific systems) or you can perhaps find a library that will allow you to do it.

AFAIK, only text files can be opened without special manipulation in most programming languages. (Database access does not count.)

It depends on what you want to do. You can pass the request to the system (only works for specific systems) or you can perhaps find a library that will allow you to do it.

AFAIK, only text files can be opened without special manipulation in most programming languages. (Database access does not count.)

you can open an ms word document with its coordinations,How?OK Look:
to make a coordination you must use this:
$opened_file=file("THE FILE PATH")
$old_array=array('','','');
$new_array=array('<b>','<u>','<i>');
$string=str_replace($old_array,$new_array,$opened_file);
To open a file use this:

Puckdropper is right, none of these code samples will actually work, as MS Word uses a binary file format, and might even refuse to open a file that had been modified with random bbcode/html added on the end. If you try very basic examples it will work, however MS Word creates all sorts of problems in the background using Word 97-2003 files. .docx files will fail entirely because of the zip file format.

What you really need to do is use COM to tell MS Word itself to handle parsing the file. You can create a new COM object with $word = new COM("word.application"); which basically opens up a copy of MS Word on the server and gives you access to it from PHP.

Take a look at this blog post on opening microsoft word files in php and extracting text. Naturally you need a Windows based server in order to do this.

How we open a ms word document file with php?

use this command.
$file=fopen("welcome.doc","r");

Comments
Don't revive a post that is 4 years old.
function parseWord($userDoc) 
{
    $fileHandle = fopen($userDoc, "r");
    $line = @fread($fileHandle, filesize($userDoc));   
    $lines = explode(chr(0x0D),$line);
    $outtext = "";
    foreach($lines as $thisline)
      {
        $pos = strpos($thisline, chr(0x00));
        if (($pos !== FALSE)||(strlen($thisline)==0))
          {
          } else {
            $outtext .= $thisline." ";
          }
      }
     $outtext = preg_replace("/[^a-zA-Z0-9\s\,\.\-\n\r\t@\/\_\(\)]/","",$outtext);
    return $outtext;
} 

$userDoc = "F:\Downloads\Amma\RESUME.doc";


$text = parseWord($userDoc);
echo $text;

Edited 3 Years Ago by mike_2000_17: Fixed formatting

I wanted to make a link to a docx file, that would open the document once clicked..and I found all those complicated answers that didn't really work lol and then I just wrote this line <a href="folder/filename.docx">open</a>
and it worked!!! so simple..that I'm scared lol
I use localhost to store the file, so do u think it opens up so easy because it's on my computer anyways? or it'll work once I put it on the server just the same?

54uydf !
I could hug and kiss you right now yes! lmao!

to append to your answer...

in order not to hardcode it create variables

e.g.
a href="upload/<?php echo "$type/$document"?>">open</a>

good luck

just downloading the file on webserver using this code <a href="folder/filename.docx">open</a>

This question has already been answered. Start a new discussion instead.