I'm trying to serve a text file for download, and I guess I have the wrong headers. Right now, it just directs the browser to that text file instead of downloading it to the desktop. If I do the same thing with a CSV file extension and CSV headers, everything works fine.
The page that generates the text file has the following headers (in MSIE, at least):
header('Content-Disposition: inline; filename="' . $reportname . '"');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
If I change the first header above to "attachment" instead of "inline" then I get another problem: If the user clicks "open," instead of "save," they get a message that the file can't be found.
For my content type header, I don't know which of the following to use for text files:
//header('Content-Type: application/download');
header('Content-Type: text/plain');
//header ("Content-Type: application/octet-stream");
When I'm exporting a CSV, I use text/x-csv and 'Content-Disposition: inline; and everything works perfectly.
Thanks for your help!