Page 1 of 1

Downloading a text file

Posted: Thu May 12, 2005 3:03 pm
by bdeonline
Hi all,
I'm needing a text file to download to the client that is generated as a php file. Thing is the browser wants to open it and when you use right click save as it wants to add the .php ending to it. I need this supper simple for a user to use is there any type of header I can use that will make this download as a simple .txt.

Or can I some how add this to a attachment and send it via email? All the examples I've seen are for attaching binary information and not simple text.

Posted: Thu May 12, 2005 4:46 pm
by php_wiz_kid
You can use the Content-Disposition header to supply a recommended filename and force the browser to display the save dialog.

Code: Select all

header('Content-Disposition: attachment; filename="downloaded.txt"');