Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with download window please 1

Status
Not open for further replies.

GregArtemides

Programmer
May 23, 2003
12
CY
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):
PHP:
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);
 
Setting a header:

header ('Content-Disposiion: attachment; filename=somefile.txt');

Should do it.

If it does not, you can also set the content-type to some non-standard value:

header ('Content-type: application/force-download');
header ('Content-Disposiion: attachment; filename=somefile.txt');

But try just the "Content-disposition" header by itself first.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
sleipnir214 Thanks a bunch. Your second option worked just fine!
 
sleipnir214 I just found out that your first option works as well! Thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top