Just came across a weird phenomenon. I've been using the zip class from Zend (A great class btw.), and I've been playing around with the output of the file. Here is the first script I used:
<?php
require ("ziplib.php");
$zipfile = new zipfile();
// add the subdirectory ... important!
$zipfile -> add_dir("iwd/");
// add the binary data stored in the string 'filedata'
$handle = fopen("iwd/icewind.txt","rb");
$filedata = fread($handle , filesize("iwd/icewind.txt"));
$zipfile -> add_file($filedata , "iwd/icewind.txt");
// the next three lines force an immediate download of the zip file:
header("Content-type: application/octet-stream");
header("Content-disposition: attachment; filename=test.zip");
echo $zipfile -> file();
?>
Now, that worked fine. It zipped the file up, and then the appropriate download box came up. No big deal right?
So then I modified the same script so that it would save the zip locally rather than popping up the download, here's the modified script:
<?php
require ("ziplib.php");
$zipfile = new zipfile();
// add the subdirectory ... important!
$zipfile -> add_dir("iwd/");
// add the binary data stored in the string 'filedata'
$handle = fopen("iwd/icewind.txt","rb");
$filedata = fread($handle , filesize("iwd/icewind.txt"));
$zipfile -> add_file($filedata , "iwd/icewind.txt");
$filename = "output.zip";
$fd = fopen ($filename, "wb");
$out = fwrite ($fd, $zipfile -> file());
fclose ($fd);
?>
<a href="output.zip">Click here to download the new zip file.</a>
However, no matter what I do when I browse to that script again, it always keeps coming up with the download prompt rather than the link. I've cleared my offline content from my browser, refreshed a bunch of times and it still does it.
Do browsers save header information from scripts somewhere that I don't know about?
Thanks for any information.