Extract .zip files using PHP

How can I extract .zip (100%) using PHP?

+5
source share
2 answers

If you have zziplib installed, you can use this code:

<?php
$zip = new ZipArchive;
if ($zip->open('test.zip') === TRUE) {
  $zip->extractTo('/my/destination/dir/');
  $zip->close();
  echo 'ok';
} else {
  echo 'failed';
}
?>

Make sure the user running php (usually nobody, apache or httpd) has write permission on the destination directory.

+16
source

Use the Zip API . The algorithm for this is:

, ,

+3

All Articles