Help with download window please

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
GregArtemides
Forum Newbie
Posts: 5
Joined: Fri Jun 13, 2003 7:03 pm

Help with download window please

Post by GregArtemides »

I want to force a download of a .txt file without IE opening it in the browser. I just need the download window to appear. How do I do it?
currently I am using (which opens the text file in the browser):

Code: Select all

header("Content-type: text/plain");
header("Content-Disposition: inline; filename=somefile.txt");
header("Expires: 0"); 
header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 
header("Pragma: public"); 

readfile($FilePath);
:?:
pootergeist
Forum Contributor
Posts: 273
Joined: Thu Feb 27, 2003 7:22 am
Location: UK

Post by pootergeist »

header("Content-Type: text/plain");
header("Content-Length: ".filesize($long_fname));
header("Content-Disposition: attachment; filename=whatever.whatever");
header("Content-Transfer-Encoding: ascii");

should suffice - amend the whatever.whatever variable values
Post Reply