note 28431 added to function.header
| From: | spike at rack1 dot php dot net | Date: | Mon, 13 Jan 2003 09:02:10 +0000 |
| Subject: | note 28431 added to function.header | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-42048@lists.php.net to get a copy of this message | ||
Based on the above notes, I have a working script that forces downloaded data to be saved as a file:
header("Expires: Mon, 26 Nov 1962 00:00:00 GMT");
header("Last-Modified: " . gmdate('D,d M Y H:i:s') . ' GMT');
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
header("Content-Type: Application/octet-stream");
header("Content-Disposition: attachment; filename=file.csv");
readfile($filename);
Now I want to do the same thing with data passed to the script as a POST variable, instead of from a
file. This opens a blank window instead of prompting a file save, and I cannot understand why:
header("Expires: Mon, 26 Nov 1962 00:00:00 GMT");
header("Last-Modified: " . gmdate('D,d M Y H:i:s') . ' GMT');
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
header("Content-Type: Application/octet-stream");
header("Content-Disposition: attachment; filename=file.csv");
echo $_POST["csv_string"];
--
http://www.php.net/manual/en/function.header.php
http://master.php.net/manage/user-notes.php?action=edit+28431
http://master.php.net/manage/user-notes.php?action=delete+28431
http://master.php.net/manage/user-notes.php?action=reject+28431