Re: [PHP] Re: Send binary files with gzip encoding disabled

2007-05-07 Thread strawks
On ven, 2007-05-04 at 17:51 +0200, Emmanuel Raulo-Kumagai wrote:
 I have about the same code except that I use application/x-zip-archive
 for the content type and it just works.
 There's no ob_* stuff in my code also.

application/x-zip-archive works (actually anything but application/zip
works, even image MIME types and others), but I think I will use
application/octet-stream.
I didn't find the list of standard MIME types, but it seems
application/zip or application/x-zip-compressed should be used here
(those are used by MUAs when sending ZIP files).

Thanks for your help.

-- 
strawks

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Send binary files with gzip encoding disabled

2007-05-04 Thread strawks
Hello,

I'm trying to send a ZIP file generated on the fly in a temporary directory.
The ZIP file is created successfully and I'm using the following code to send 
it to the client :

$filesize=filesize($path);
$mimetype='application/zip';

// Make sure there's not anything else left
ob_clean_all();

// Start sending headers
header(Pragma: public); // required
header(Expires: 0);
header(Cache-Control: must-revalidate, post-check=0, pre-check=0);
header(Cache-Control: private,false); // required for certain browsers
header(Content-Transfer-Encoding: binary);
header(Content-Description: File Transfer);
header(Content-Type: .$mimetype);
header(Content-Disposition: attachment; filename=\.$name.\; );
header(Content-Length: .$filesize);

[EMAIL PROTECTED]($path,rb); 
while([EMAIL PROTECTED]($fp))
{
set_time_limit(0);
print @fread($fp, 8192);
}
@fclose($fp);

The ob_clean_all() function :
function ob_clean_all () {
$ob_active = ob_get_length () !== false;
while($ob_active) {
ob_end_clean();
$ob_active = ob_get_length () !== false;
}

return true;
}

The problem is that Apache process the output throught gzip and so drop the 
Content-Length header replacing it with a chunked transfer. This should work 
fine but Internet Explorer simply save the raw gzip compressed data instead of 
the ZIP archive. However this works fine with Firefox.

gzip encoding is unecessary since I'm transfering a ZIP archive, so I think 
just disabling it should solve the problem, but I haven't found how to do this.

Any help would be appreciated.

-- 
strawks.


 
-
 Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! 
Profitez des connaissances, des opinions et des expériences des internautes sur 
Yahoo! Questions/Réponses.