Skip to content

Instantly share code, notes, and snippets.

@baptistedonaux
Last active December 30, 2015 05:59
Show Gist options
  • Save baptistedonaux/7785999 to your computer and use it in GitHub Desktop.
Save baptistedonaux/7785999 to your computer and use it in GitHub Desktop.
<?php
function unzip($path_zip, $tmp_folder = "/tmp/") {
$all_files = array();
$zip = zip_open($path_zip);
if ($zip) {
$stream = zip_read($zip);
while ($stream) {
var_dump($zip_name);
$zip_name = zip_entry_name($stream);
$path_file_unzip = $tmp_folder.$zip_name;
$dir_folder = substr($path_file_unzip, 0, strrpos($path_file_unzip, "/"));
mkdir($dir_folder, 0777, true);
$fp = fopen($path_file_unzip, "w");
array_push($all_files, $path_file_unzip);
if (zip_entry_open($zip, $stream, "r")) {
$buf = zip_entry_read($stream, zip_entry_filesize($stream));
fwrite($fp, "$buf");
zip_entry_close($stream);
fclose($fp);
}
$stream = zip_read($zip);
}
zip_close($zip);
}
return $all_files;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment