First thing, do you want the visitor to receive the file as-is (gz 
encoded) ? Or should it be decoded automatically to text ?

In the first case, the browser shouldn't be aware of the encoding type 
(Content-Encoding header).

You should only send 1 Content-Type header.

The Content-Disposition header is nothing but trouble, and this is 
mainly caused by MSIE 5.5 .
Microsoft managed to supply an update that changes the behaviour of MSIE 
5.5 regarding this
while the version still is 5.5 .. So there's no way to tell what header 
to sent for it to work properly.

You could also expiriment with the extra keywords 'inline' and 'attachment'.

header( 'Content-Disposition: attachment; filename=text.gz' );

But as I said, since browser behaviour varies on this header (even 
within same browser type/version)
it's not easy to implement correctly for all browsers.

I'm also not sure wether this header made it to the HTTP1.1 specs, but 
if you still want to use it I recommend
consulting the website of W3C (, they should at 
least have some notes about it.


Krzysztof Kocjan wrote:

> Hi
> I have big problem with headers which I send to www browser: IE 5.5 
> and Netscape 6.2. On my web site I have PHP script to download huge 
> text files to client side. The text file is compressed by gzip program 
> before it will be downloaded to client. My problem is how to send to 
> www browser correct headers to download gziped file for example 
> "text.gz" and force www browser to store this file with name "text.gz".
> I tested with protocol http sending headers like below, but it work 
> only with IE 5.5. Using Netscape 6.2 downloaded file should be stored 
> as "text.gz" but is stored as name of the PHP script. There is PHP 
> code with headers I send to www browser:
> header( 'Content-Encoding: zip');
> header( 'Content-Length: 100' );
> header( 'Content-Location: text.gz' );
> header( 'Content-Type: application/octet-stream' );
> header( 'Content-Type: application/zip' );
> header( 'Content-Disposition: filename=text.gz' );
> readfile( 'text.gz' );
> exit();
> When I switched the protocol from http to https the I've got second 
> problem. Downloading gziped file text.gz using IE 5.5 it didn't work 
> completely. IE showed me strange error message with information that 
> this resource couldn't be opened. Using Netscape 6.2 the problem is 
> the same.
> Thank You for any suggestions.
> Krzysiek
> ----------------------------------------------------------------------
> Najlepsza bezplatna poczta w Polsce >>>
> Jako jedyna oceniona bardzo dobrze przez Komputer Swiat (nr 5/2002)

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to