GZIP extract all files?
Moderator: General Moderators
- JAB Creations
- DevNet Resident
- Posts: 2341
- Joined: Thu Jan 13, 2005 6:44 pm
- Location: Sarasota Florida
- Contact:
GZIP extract all files?
I've been reading the GZIP functions on php.net and frankly I'm still a bit baffled at how to extract all the files from a GZIP archive? Could someone please point me in the correct direction?
- JAB Creations
- DevNet Resident
- Posts: 2341
- Joined: Thu Jan 13, 2005 6:44 pm
- Location: Sarasota Florida
- Contact:
Re: GZIP extract all files?
Looks like read is what I want (why it's not called extract is beyond me)...
This script I just wrote is returning true though no files have been extracted, what am I doing wrong?
This script I just wrote is returning true though no files have been extracted, what am I doing wrong?
Code: Select all
$filename = "test.gz";
$zd = gzopen($filename, "r");
if (!$zd) {echo 'OPEN: did not work?<br />';}
else {echo 'OPEN: worked?<br />';}
$contents = gzread($zd, 100000);
if (!$contents) {echo 'READ: did not work?';}
else {echo 'READ: worked?';}
gzclose($zd);-
filippo.toso
- Forum Commoner
- Posts: 30
- Joined: Thu Aug 07, 2008 7:18 am
- Location: Italy
- Contact:
Re: GZIP extract all files?
A GZIP archive contains only 1 file / stream of data. To insert multiple files/directories into a GZIP file they must be "packed" using a tool like TAR.
In your code, the $contents variables contains the first 100000 uncompressed bytes of the test.gz file.
In your code, the $contents variables contains the first 100000 uncompressed bytes of the test.gz file.
- JAB Creations
- DevNet Resident
- Posts: 2341
- Joined: Thu Jan 13, 2005 6:44 pm
- Location: Sarasota Florida
- Contact:
Re: GZIP extract all files?
Thanks, I guess I'll look for ZIP support then. I've really only used GZIP with access logs (server generated of course) so I never knew about the one file limitation. GZIP's one file limitation makes no sense, especially if it's been around for so long.