note 64815 deleted from function.header by bjori
| From: | bjori@php.net | Date: | Fri, 21 Apr 2006 07:59:59 +0000 |
| Subject: | note 64815 deleted from function.header by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-108898@lists.php.net to get a copy of this message | ||
Note Submitter: dibakar at talash dot net
Reason: bad code
----
IE Bug makes it confuse that why the hell the code which works in the other browser's does not
work over here. Well, later on I found our most intelligent browser just become little confuse with
file extension to download and file url(.php) it have. One way around is generate the file in your
server and provide the path as url to download. But, I do not like that option then I came around
with this one which fullfill my download on fly and it works with every browser family.
Do not loose patience and time. Just copy this header info for your file-download feature. And have
a good sleep.
//Check user browser agent [IE OR Others]
if(isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/MSIE/",
$_SERVER['HTTP_USER_AGENT'])) {
//IE bug featured workaround
ini_set('zlib.output_compression', 'Off');
header("Content-type: application/force-download");
} else {
# This line will stream the file to the user rather than spray it across the screen
header("Content-type: application/octet-stream");
}
# Sent the headers as file attachement to be downloaded to the browser
header("Content-Disposition: attachment; filename=".ExcelGenerator::$excelFileName);
header("Pragma: no-cache");
header("Expires: 0");
You've done it. and now enjoy download.