How do I write a Php script that will allow user to download a word file form the server to his local computer .
Does it have to be PHP? Why not FTP? If you own a Mac or Linux system you can even use wget, scp or rcp in terminal mode on the local computer.
If no to all of those, please take the time to explain if you need to automate it so a file is sent without user intervention via a task scheduler, or if you need a human being to initiate the download? If the latter, what would be your perfect scenario to accomplish that?
For now, the advice is pretty generic beyond what I said in my first paragraph. Install a file manager in PHP on the server like this one, configure it to allow access from a given username for that file or folder which contains it, the user on the local computer browses to the web site hosting the file manager and downloads directly. This means setup a simple website on the server.
I note with caution that simply allowing world access to the server, i.e. a simple web site without PHP, i.e. just a directory index display allowing anyone to download the file is a security vulnerability. But, alas, it's another way, too. So my advice about the file manager software is to allow a secure environment, plus the uploads on the server can be managed too. Just thinking ahead!
Nikiitea's advice is excellent. I wish to expand a bit on that...
In previous replies it seems Virtuemart and I thought you meant a complete solution as you mentioned both server and local, hence my questions and suggestion to use a file manager which really is excellent for this type of thing. File managers typically use the function noted by nikiitea or code that does similar.
If all you need is the portion of PHP code to specifically read a .doc file on the server and initiate a client download dialog box please consider the following to be added within your existing script:
Bookmarks