The problem is that $zip->addFile passed the same two parameters.
According to the documentation :
bool ZipArchive :: addFile (string $ filename [, string $ localname ])
file name
The path to the file to be added.
Localname
local name inside the zip archive.
This means that the first parameter is the path to the actual file in the file system, and the second is the path and file name that the file will have in the archive.
When delivering the second parameter, you want to remove the path from it when adding it to the zip archive. For example, on Unix-based systems, this would look like this:
$new_filename = substr($file,strrpos($file,'/') + 1); $zip->addFile($file,$new_filename);
Nathan Osman Oct 22 '10 at 1:05 2010-10-22 01:05
source share