note 83384 added to function.header

From: Date: Fri, 23 May 2008 07:54:34 +0000
Subject: note 83384 added to function.header
Groups: php.notes 
Request: Send a blank email to php-notes+get-139634@lists.php.net to get a copy of this message
Hi, I was trying to save the '.xls' on user machine, which works correctly on Firefox(developer friendly) but not on Microsoft's IE(Microsoft friendly); after searching on the net, i found this code which works on both the browser. Source link: http://www.webdeveloper.com/forum/archive/index.php/t-30248.html here is the code: ------------------------- <?php // downloading a file $filename = $_GET['path']; // fix for IE catching or PHP bug issue header("Pragma: public"); header("Expires: 0"); // set expiration time header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); // browser must download file from server instead of cache // force download dialog header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-Type: application/download"); // use the Content-Disposition header to supply a recommended filename and // force the browser to display the save dialog. header("Content-Disposition: attachment; filename=".basename($filename).";"); /* The Content-transfer-encoding header should be binary, since the file will be read directly from the disk and the raw bytes passed to the downloading computer. The Content-length header is useful to set for downloads. The browser will be able to show a progress meter as a file downloads. The content-lenght can be determines by filesize function returns the size of a file. */ header("Content-Transfer-Encoding: binary"); header("Content-Length: ".filesize($filename)); @readfile($filename); exit(0); ?> ---- Server IP: 203.199.69.133 Probable Submitter: 59.162.2.134 ---- Manual Page -- http://www.php.net/manual/en/function.header.php Edit -- https://master.php.net/note/edit/83384 Del: integrated -- https://master.php.net/note/delete/83384/integrated Del: useless -- https://master.php.net/note/delete/83384/useless Del: bad code -- https://master.php.net/note/delete/83384/bad+code Del: spam -- https://master.php.net/note/delete/83384/spam Del: non-english -- https://master.php.net/note/delete/83384/non-english Del: in docs -- https://master.php.net/note/delete/83384/in+docs Del: other reasons-- https://master.php.net/note/delete/83384 Reject -- https://master.php.net/note/reject/83384 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#139634) next »