Forum Moderators: coopster

Message Too Old, No Replies

Problem with gzencode()

         

DrDoc

3:04 am on Mar 31, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Consider the following lines of code:
if($gzip) { 
echo " Generating gzip...\n";
$MIME = "application/gzip";
$data = gzencode($data,9);
$filename .= ".gz";
}
echo " Saving file as $filename...\n";
$fh = fopen("temp/$filename", "w");
fwrite($fh,$data);
fclose($fh);

As long as I don't use the gzip function ($gzip=0) everything works fine, but as soon as I gzencode the data, it gets messed up. Any clue why? :(

DrDoc

4:40 am on Mar 31, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Seems like it works as long as I don't specify the compression level... (?)

coopster

1:15 pm on Mar 31, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



What version of PHP? Compression level was added in PHP 4.2.

DoppyNL

1:18 pm on Mar 31, 2004 (gmt 0)

10+ Year Member



you are outputting plain text (the messages to inform the user) AND the actual gzipped file into the same stream.
Effectivly making a big mess.

Remove the echo statements and just send the file and it should be ok.

DrDoc

1:50 am on Apr 2, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Not same stream...
The echo statements go to the user (commandline app). The gzipped data goes in a file.