Unzipping gz file on server with php

software development


Hi all

Does anyone know how to unzip a file on dreamhost. I have tried a number of classes and files to unzip but have yet to get one to work.

Not sure if this is because it is a gz file but any help would be appreciated.
Save [color=#CC0000]$48[/color] on your hosting by using [color=#CC0000]ZASTIL[/color] (full details here)


From your happy dreamhost SSH prompt type:man gunzip…and all will become clear


What nedcon said…

You can also find lots of approaches to this in the online documentation at php.net, one of the “simplest” being just using php’s exec() and gunzip or unzip (both of which are available on Dreamhost). :wink:


<?php $za = new ZipArchive(); $za->open('test_with_comment.zip'); print_r($za); var_dump($za); echo "numFiles: " . $za->numFiles . "\n"; echo "status: " . $za->status . "\n"; echo "statusSys: " . $za->statusSys . "\n"; echo "filename: " . $za->filename . "\n"; echo "comment: " . $za->comment . "\n"; for ($i=0; $i<$za->numFiles;$i++) { echo "index: $i\n"; print_r($za->statIndex($i)); } echo "numFile:" . $za->numFiles . "\n"; ?>

This does not work look at this link http://www.mobile97.com/sample.php

Save [color=#CC0000]$48[/color] on your hosting by using [color=#CC0000]ZASTIL[/color] as your promocode. (full details here)


You shouldn’t use ZipArchive when manipulating a gz file. Why don’t you use zlib for your gz files. Your using php to manipulate gz files do you? Then take a look at http://nl2.php.net/manual/en/ref.zlib.php
(hopefully php.net will switch automatically to your language, if not open http://php.net and search at ‘zlib’)

Examples how to write, open and read gz files is included in this page. Besides that I used this information and am able to write, open and read gz files on the fly.