Help with Content-Type and Content downloading

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
Joat
Forum Newbie
Posts: 2
Joined: Thu Oct 30, 2003 12:43 pm

Help with Content-Type and Content downloading

Post by Joat »

Hi folks,

this problem is making me insane, so any help would be appreciated.

What I want to do is send the content of a web page as a downloaded file.

My code (greatly simplified) in file test.php is this:
<?php
header("Pragma: no-cache");
header("Content-Type: text/x-delimtext; charset=iso-8859-1; name=\"myresults.sql\"");
header("Content-disposition: attachment; filename=myresults.sql");

#echo "line one\n";
#echo "line two\n";
#echo "line three\n";
?>

in theory, the downloaded file would contain the text:
line one
line two
line three

and would be named myresults.sql

Instead, what I'm getting is a download box, asking me if I want to download test.php and if I click save or open it it tells me IE was unable to open the file.

I've seen this done with phpbb2, so I know it can be done. but I'm having trouble making it work.

Thanks in advance,

Joat
Joat
Forum Newbie
Posts: 2
Joined: Thu Oct 30, 2003 12:43 pm

Post by Joat »

Sometimes, Life is cruel.

The above works on Linux / Apache.

It does not work on 2000 / IIS.

While I can live with this, would love to know why.

Thanks,

Joat
Post Reply