Php – send a file to client


I want to write a text file in the server through Php, and have the client to download that file.

How would i do that?

Essentially the client should be able to download the file from the server.

Best Solution

This is the best way to do it, supposing you don't want the user to see the real URL of the file.

  header("Content-disposition: attachment;filename=$filename");

Additionally, you could protect your files with mod_access.