I am using the following code to get files to add to a zip file, however, when the zip runs is also zips the parent folder. I think the probelm is that I do not undersand the difference between "." and ".." when i only want to add all files in zip, and not include any subfolders.
$filenames = array('.');
function browse($dir) {
global $filenames;
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && is_file($dir.'/'.$file)) {
$filenames[] = $dir.'/'.$file;
}
else if ($file != "." && $file != ".." && is_dir($dir.'/'.$file)) {
browse($dir.'/'.$file);
}
}
closedir($handle);
}
return $filenames;
}
browse($directory);
Am looking along the right lines?