I have created a PHP script that uploads file and extract it and get folder name inside the zip and insert its name and path into db. However it doesn't extract the folder name from zip archive and doesn't gets path name like I want. It extracts all direcotories and file names I just want directory names. Lets say I have zip file called abc.zip and it contains folders like this
a ->b->c
ab ->bc
What I want is to be able to get only parnet directory names like a and b currently it gets all directory names and file names.
$zip = new ZipArchive;
$zip->open($filen);
$zip->extractTo($path);
$zip->close();
$zip = new ZipArchive;
if ($zip->open($filen) === true) {
for($i = 0; $i < $zip->numFiles; $i++) {
$filename = $zip->getNameIndex($i);
$fileinfo = pathinfo($filename);
$db->con->query("Insert into files (rand) values ('$filename')");
}
$zip->close();
}