note 39349 deleted from function.readfile by tomsommer
| From: | tomsommer@php.net | Date: | Mon, 09 Aug 2004 06:49:12 +0000 |
| Subject: | note 39349 deleted from function.readfile by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-74295@lists.php.net to get a copy of this message | ||
Note Submitter: fai
----
If you would like dynamic content to be forced downloading with no need for making a temporary copy
in the remote harddisk, the below code may assist.
This is useful in those servers that you are not permitted to write files but you need to modify the
file before starting downloading.
<?php
$filename="dynamiccontent.txt";
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Disposition: attachment; filename=".basename($filename).";");
header("Content-Transfer-Encoding: binary");
//const
$content = "";
//varied
for ($i=0;$i<=10;++$i) $content.=$i"";
//from query string.
$content .= $HTTP_GET_VARS['message'];
//file size
$size=array_sum(count_chars ($content));
header("Content-Length: ".$size);
echo $content;
exit();
?>