I have used the following code to unzip a zip folder after upload.
/* here it is really happening */
if(move_uploaded_file($source, $targetzip)) {
$zip = new ZipArchive();
$x = $zip->open($targetzip); // open the zip file to extract
if ($x === true) {
echo $targetdir; exit;
$zip->extractTo($targetdir); // place in the directory with same name
$zip->close();
unlink($targetzip);
}
$message = "Your .zip file was uploaded and unpacked.";
} else {
$message = "There was a problem with the upload. Please try again.";
}
It is working fine. But the only problem is the that the folder is replaced by the new one uploaded. I want to merge it.
Suppose i have a zip folder. One.zip a b c
When i upload this, it should merge with the (One) folder which is already in the upload server. So the previous folders in the (One) folder should not be replaced.
I think It is understandable now. Please help to do the trick.