note 24770 added to function.header

From: Date: Wed, 28 Aug 2002 10:00:53 +0000
Subject: note 24770 added to function.header
Groups: php.notes 
Request: Send a blank email to php-notes+get-35889@lists.php.net to get a copy of this message
Here's one for all the people that really want to force any type of download, if it's text, or a word document, or anything else, this works. [code] $attachment = (strstr($HTTP_USER_AGENT, "MSIE")) ? "" : " attachment"; // IE 5.5 fix. $string = " <html> <head> <title>Hellooo world!</title> </head> <body> <div style='position: absolute; left:200px; top:200px; width: 200px; height:200px; border: 1 solid #ABABAB; font-family:verdana; font-size:10px; font-weight:bold; background-color:#EFEFEF; color: #ABABAB;'> Hi m8, i'm a little file that's just been downloaded to your pc :) </div> </body> </html>"; header("Cache-control: private"); // another fix for IE header("Content-Type: application/octet-stream"); header("Content-Length: ".strlen($string)); header("Content-Disposition: attachment; filename=iamalittlehtmlfile."."html"); echo $string; [/code] you can replace the string by any file you just fpassthru. just make sure that the '.' for the filename is set before the extention that's concatted to it. I know it's weird, but if u don't do it like this, and try to send a word document, it will just open in the browser. -- http://www.php.net/manual/en/function.header.php http://master.php.net/manage/user-notes.php?action=edit+24770 http://master.php.net/manage/user-notes.php?action=delete+24770 http://master.php.net/manage/user-notes.php?action=reject+24770

« previous php.notes (#35889) next »