note 88038 added to function.header

From: Date: Wed, 07 Jan 2009 10:11:17 +0000
Subject: note 88038 added to function.header
Groups: php.notes 
Request: Send a blank email to php-notes+get-148914@lists.php.net to get a copy of this message
When you are trying to download a file using PHP it´s important to take into acount the definition of de Header element. I have seen various examples where the people use a header("Content-Type: application/octet-stream"); header("Content-Disposition: attachment; filename=\"".$filename."\";"); however in adition to this is important add the definition of the cache because if you dont do it you will have problems with some navigators for example IE 7.0 under https protocol will show you a message saying that the file is not available. here is a working example: header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private",false); header ( "Content-Type: $filedatatype" ); header("Content-Disposition: attachment; filename=\"".$FileObj->name."\";"); header("Content-Transfer-Encoding:­ binary"); header("Content-Length: ".$filesize); readfile($file); exit; where $filedatatype is the data type of the file for example: application/pdf ---- Server IP: 130.206.1.5 Probable Submitter: 195.5.85.106 ---- Manual Page -- http://www.php.net/manual/en/function.header.php Edit -- https://master.php.net/note/edit/88038 Del: integrated -- https://master.php.net/note/delete/88038/integrated Del: useless -- https://master.php.net/note/delete/88038/useless Del: bad code -- https://master.php.net/note/delete/88038/bad+code Del: spam -- https://master.php.net/note/delete/88038/spam Del: non-english -- https://master.php.net/note/delete/88038/non-english Del: in docs -- https://master.php.net/note/delete/88038/in+docs Del: other reasons-- https://master.php.net/note/delete/88038 Reject -- https://master.php.net/note/reject/88038 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#148914) next »