I want to unzip directorires.
That means i have a zipped directory name with xxx.zip
.In manuall i right clicked on the zipped directory and do extract folder,then i got an unzipped dirtectory with name xxx
and also in this directory have a same directory xxx
.In the subfolder will contained the files.
That means, xxx->xxx->files this is the heirarchi of unzipped folder.
So in my site i want to unzipp a directory using php code.
How can i do this? I need only xxx->files
not xxx->xxx->files
structure.
How can i do this?
<?php
$zip = zip_open("zip.zip");
if ($zip) {
while ($zip_entry = zip_read($zip)) {
$fp = fopen("zip/".zip_entry_name($zip_entry), "w");
if (zip_entry_open($zip, $zip_entry, "r")) {
$buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
fwrite($fp,"$buf");
zip_entry_close($zip_entry);
fclose($fp);
}
}
zip_close($zip);
}
?>
See this http://www.php.net/manual/en/ziparchive.extractto.php
$zip = new ZipArchive;
if ($zip->open('E:\pathto\zip\ashok_subedi.zip') === TRUE) {
$zip->extractTo('E:\pathto\extrac\myzip');
$zip->close();
echo 'ok';
} else {
echo 'failed';
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With