Posted by: ranacse05 on: March 20, 2008
A few days ago i was looking for a script witch one will help me to unzip a file using PHP . There is 2 different ways to do it.One just execute a commend to unzip the file in the shell using PHP and another one is using library functions .Then i found this script from phpxperts.
// create object
$zip = new ZipArchive() ;
// open archive
if ($zip->open(‘archive. zip’) !== TRUE) {
die (‘Could not open archive’);
}
// extract contents to destination directory
$zip->extractTo(‘/ tmp/extracted/ ‘);
// close archive
// print success message
$zip->close();
echo ‘Archive extracted to directory’;
Thanks to share this stuff
I think its helpful.
Thanks a lot man, this works just fine with zipped images is great!!
yeah nice but wheres the rest!
Aint there meant to be a class lol
Usefull.
thanxx
Thanks for simple script.
Hi,
I am using the above code to unzip a zip file. But it shows that Class ‘ZipArchive’ not found.
Please help me.
Thanks, Very nice, Got after a long search. Thanks
It looks like you need to have php compiled with this library (found here)included. I’d guess that some hosts do this by default, but some (mine included) don’t.
I’ve found it’s usually easier to just use exec() and have php do it from the command line.
Hi,
Thank you so much for such a simple script. This is really helpful.
Hi,
It’s Usefull, thanks. But I am using the above code to unzip a zip file on linux server can’t effect. Please help me.
Hi…
anyone knows how to access a zip file from a server where path to server is given as a http url……i have tride to give path in zip->open …but doesn’t wrks..
i hope somedbody finds me soln..:)..
Hi….
atlast soltn found…just use copy keyword…..rest done…:)
Many thanks!
help
if php does not have built in zip support using system call to the unzip binarystatus ?
March 20, 2008 at 4:46 pm
thanx..