note 64815 added to function.header

From: Date: Fri, 21 Apr 2006 05:30:18 +0000
Subject: note 64815 added to function.header
Groups: php.notes 
Request: Send a blank email to php-notes+get-108888@lists.php.net to get a copy of this message
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. ---- Server IP: 203.199.124.111 Probable Submitter: 125.22.10.86 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.header.php Edit -- http://master.php.net/note/edit/64815 Del: integrated -- http://master.php.net/note/delete/64815/integrated Del: useless -- http://master.php.net/note/delete/64815/useless Del: bad code -- http://master.php.net/note/delete/64815/bad+code Del: spam -- http://master.php.net/note/delete/64815/spam Del: non-english -- http://master.php.net/note/delete/64815/non-english Del: in docs -- http://master.php.net/note/delete/64815/in+docs Del: other reasons-- http://master.php.net/note/delete/64815 Reject -- http://master.php.net/note/reject/64815 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#108888) next »