note 39349 added to function.readfile
| From: | fai at rn2 dot php dot net | Date: | Sun, 25 Jan 2004 17:27:24 +0000 |
| Subject: | note 39349 added to function.readfile | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-64164@lists.php.net to get a copy of this message | ||
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();
?>
----
Manual Page -- http://www.php.net/manual/en/function.readfile.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+39349
Delete -- http://master.php.net/manage/user-notes.php?action=delete+39349&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+39349&report=yes
Search -- http://master.php.net/manage/user-notes.php