note 88038 deleted from function.header by tularis

From: Date: Fri, 04 Apr 2014 11:26:53 +0000
Subject: note 88038 deleted from function.header by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-199152@lists.php.net to get a copy of this message
Note Submitter: eonrglez at gmail dot com ---- 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 <?php 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: <?php 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

« previous php.notes (#199152) next »