filedownload and output buffering
| From: | viraj | Date: | Tue, 12 Dec 2006 09:37:59 +0000 |
| Subject: | filedownload and output buffering | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-245732@lists.php.net to get a copy of this message | ||
hi all,
i have a small script which shows some information inside a html table
and then pushes a file to save on to users desktop.
but with the following code it download the file and stay without
outputting the html table to browser.
i tried with out put buffering functions, but still no luck (it seems
i'm not clear about those functions yet..). could somebody please help
me on this?
many thanks
~viraj
<?php
function my_callback($content) {
header('Content-type: application/binary; charset=iso-8859-1');
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
header("Pragma: public");
header("Content-Disposition: attachment; filename=\"Test.url\"");
$content .= "[InternetShortcut]\r\n" .
"URL=http://192.168.1.71/\r\n" .
"IDList=" .
"IconFile=http://192.168.1.71/favicon.ico\r\n" .
"IconIndex=1\r\n" .
"[{000214A0-0000-0000-C000-000000000046}]\r\n" .
"Prop3=19,2\r\n";
return $content;} ob_start('my_callback'); getBody(); ob_end_flush(); function getBody() { ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> <table cellspacing="0" cellpadding="0" width="780" align="center" border="1">
<tbody>
<tr>
<td class="outerBorder" valign="top" width="780">Some
information goes here..</td>
</tr>
</tbody>
</table>
</body>
</html>
<?php
}
?>