I've got the following code: error_reporting(E_ALL); header("Content-type: text/rtf"); header("Content-Disposition: attachment; filename=\"custom_pan.rtf\""); if(!headers_sent()){ die("didn't work"); } and all it returns is "didn't work".... I can't figure out why the headers aren't sending. Any ideas? (I just want it to ask the person to download it or open it with microsoft word or something.) Any ideas? I'm using a linux server I know nothing about, running PHP 4.1 if that makes a difference.
I've had a few things like this with Adobe files - though I've never actually tested the return. behaviourly - the Client will test for an association and open it the application (within the browser in the case of adobe and word.) If there is no file association the fact you've specified a filename means the user will be prompted to save the file. I've not yet discovered how to recognise whether or not the attachment was actually opened. I'd be interested in this too. As far as I know if the client is connected they will have received the headers. *Edit* Not much use i'm afraid! - I just realised I didn;t answer your question!
Exact code works fine in both FF and IE on my dev box. As you can see, that's PHP5 though. Not got any PHP4 boxes left to try it on.
I found out the problem.... Our friend, Mr. IE, says 5767 Kbps is too slow of a download speed, so we'll store header information for you in cache, to speed things up. When I hit refresh, it keeps the headers in cache and spits out the contents of the files. So if you have a script that spits out headers, make sure it works every time it is accessed, otherwise the client may have to close their browser, start it up again, and go back to the page after headers have been cleared from cash.
Ok, so this is a REPLY, not an EDIT. What I said was... "Can't you just send a no-cache header?" <EDiT> eg PHP: <?php // Date in the past header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // always modified header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // HTTP/1.1 header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); // HTTP/1.0 header("Pragma: no-cache"); ?> http://www.zend.com/manual/function.header.php