Shoutbox

PHP & IE using headers to add file as an attachment... - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: PHP & IE using headers to add file as an attachment... (/showthread.php?tid=93470)

PHP & IE using headers to add file as an attachment... by matty on 01-08-2010 at 04:07 PM

Ok so I have a situation and it is confusing me as this works fine in Firefox.

PHP code:
<?
    $path = '/home/ss/plsc/';
    $f = scandir( $path );
    rsort ( $f );
 
    $file = '/home/ss/plsc/'.$f[0];
    header("Pragma: public");
    header("Expires: 0");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Cache-Control: public");
    header("Content-Description: File Transfer");
    header("Content-Type: application/zip");
    header("Content-Disposition: attachment; filename=\"".basename($file)."\"");
    header("Content-Transfer-Encoding: binary");
    header('Content-Length: ' . filesize($file));
    readfile($file);
?>


I have the above code. This simply grabs the last PLSC built on the server for download. There are no problems at all in Firefox. However in IE you end up with a PLSC that inside has the PLSC again without an extension... I also added the mime type using .htaccess

[Image: attachment.php?pid=984168]

I am at a loss...
RE: PHP & IE using headers to add file as an attachment... by Mnjul on 01-08-2010 at 04:18 PM

It appears that your plsc file is actually tar-gzipped, not zipped. How did you compress to make the plsc file?


RE: PHP & IE using headers to add file as an attachment... by matty on 01-08-2010 at 04:22 PM

quote:
Originally posted by Mnjul
It appears that your plsc file is actually tar-gzipped, not zipped. How did you compress to make the plsc file?
I used a PHP Zip library. That file inside the zip you see is a ZIP without an extension. IE downloaded it as a GZIP Firefox downloads it as a ZIP.
RE: PHP & IE using headers to add file as an attachment... by Mnjul on 01-08-2010 at 04:34 PM

Hmm. :-/

Try adding a
Content-Encoding: gzip
header.