Hi, I use php to zip up the content of a folder. That works fine. But because of where the script and the subfolder are located in relation to each other I end up with loads of folders in the zip but I only want the files in there. Any help would be great. The structure is like this. when I open the zip all of the folder and subfolders are in the zip file as well but I only want to have the files in the zip folder. Any help?
I would have to see the script you are using. If you want to add all file files to one folder, removing their folder relationship, you would just keep adding the files to the zip archive and make sure there are no addEmptyDir functions called.
if you have ZIP module compiled in your php then you can do it this way: <?php $zip = new ZipArchive; if ($zip->open('output.zip') === TRUE) { $zip->addFile('/path/to/file1.jpg', 'file1.jpg'); $zip->addFile('/path/to/file2.jpg', 'file1.jpg'); $zip->addFile('/path/to/file3.jpg', 'file1.jpg'); $zip->close(); echo 'ok'; } else { echo 'failed'; } ?> if you are in an *NIX environment and it has the ZIP package installed .. you can do it this way <?php exec('/usr/bin/zip -r -D output.zip folder'); //Note: When safe mode is enabled, you can only execute files within the safe_mode_exec_dir. For practical reasons, it is currently not allowed to have .. components in the path to the executable. ?>