Page 1 of 1

gzread zip problem

Posted: Thu Jun 10, 2004 1:03 am
by amolkad
HI,

Follwoing is code I am using for reading zip and writing in another file.
But it do not read complete file.It may be filesize problem.
My zlib version is 1.2.0.7
PHP Version 4.3.3
Apache 2.0

function gunzip($filename,$destfile)
{
$zp = gzopen($filename, "r");
$fp = fopen($destfile, "w");
fputs($fp, gzread($zp, filesize($filename))) ;
fclose($fp);
gzclose($zp);
}

Posted: Thu Jun 10, 2004 1:07 am
by markl999
If all your doing is opening it, reading it and writing out to another file, why not just use copy ?

Posted: Thu Jun 10, 2004 1:13 am
by Weirdan
you shouldn't use filesize($filename) as a parameter to gzread:
PHP Manual wrote: gzread() reads up to length bytes from the gz-file pointer referenced by zp. Reading stops when length (uncompressed) bytes have been read or EOF is reached, whichever comes first.

Posted: Thu Jun 10, 2004 1:14 am
by Weirdan
markl999 wrote:If all your doing is opening it, reading it and writing out to another file, why not just use copy ?
He's decompressing the file, not just copy it.

Posted: Thu Jun 10, 2004 1:18 am
by markl999
He's decompressing the file, not just copy it.
Ah, quite right.
/me stops trying to help at 7:20am and no sleep

Posted: Thu Jun 10, 2004 1:37 am
by amolkad
Thanks for help,

I will try by removing filesize.