see this http://stackoverflow.com/questions/2190540/adds-an-empty-directory-in-the-archive i cant use that code
function addFolderToZip($dir, $zipArchive, $zipdir = ''){
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
//Add the directory
$zipArchive->addEmptyDir($dir);
// Loop through all the files
while (($file = readdir($dh)) !== false) {
//If it's a folder, run the function again!
if(!is_file($dir . $file)){
// Skip parent and root directories
if( ($file !== ".") && ($file !== "..")){
addFolderToZip($dir . $file . "/", $zipArchive, $zipdir . $file . "/");
}
}else{
// Add the files
$zipArchive->addFile($dir . $file, $zipdir . $file);
}
}
}
please write example for me
the second problem is tooooo complex when i using addfile function its will add and appear in the archive as a file and this great now when i using
$z = new ZipArchive();
$z->open('test.zip')
for ($i=0; $i< $z->numFiles;$i++) {
$aZipDtls = $z->statIndex($i);
echo $aZipDtls['name'];
}
its now show if i add a file in folder like that
$zip->addFile('/path/to/index.txt', 'dir/newname.txt');
it show in the winrar soft a dir then a file but in the code its show it as one file file like that in winrar
dir/
dir/newname.txt
in my php system just only show one file without its dir like that
dir/newname.txt
this mean its imposible to add a new file in a dir