i am trying to extract the contents of a zipped folder into the root of the website i have a directory called zip.zip but everything i try creates a directory called zip, is there a way to extract the contents into the root
<?php
$zip = new ZipArchive;
if ($zip->open("zip.zip")){
$path = getcwd() . "/";
$path = str_replace("\\","/",$path);
echo $path;
echo $zip->extractTo($path);
$zip->close();
echo 'Done.';
} else {
echo "Error";
}
?>
thank you
I have solved this
<?php
$path = 'zip.zip';
$zip = new ZipArchive;
if ($zip->open($path) === true) {
for($i = 0; $i < $zip->numFiles; $i++) {
$filename = $zip->getNameIndex($i);
$fileinfo = pathinfo($filename);
copy("zip://".$path."#".$filename, "".$fileinfo['basename']);
}
$zip->close();
}
?>
thanks any way