random1 Posted September 10, 2008 Share Posted September 10, 2008 Hi All, I have the following code for zipping up a folder: ini_set('max_execution_time', 50000); // 50 seconds // create object $zip = new ZipArchive(); // open archive if ($zip->open($destinationpath, ZIPARCHIVE::CREATE) !== TRUE) { return 'Could not open archive ' . $destinationpath; } // initialize an iterator // pass it the directory to be processed $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($folders)); // iterate over the directory // add each file found to the archive foreach ($iterator as $key=>$value) { $zip->addFile(realpath($key), $key) or die ('ERROR: Could not add file: ' . $key); } This code works fine for some directories but others trigger: die ('ERROR: Could not add file: ' . $key); I think the issue has to do with: $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($folders)); Is this way to do this? Is there an alternative? Link to comment https://forums.phpfreaks.com/topic/123542-file-zipping-using-recursiveiteratoriterator/ Share on other sites More sharing options...
vicodin Posted September 10, 2008 Share Posted September 10, 2008 Check your permissions on the folders before doing anything... there is no reason i can think of besides you have the wrong permissions for it to work on one folder but not another. Link to comment https://forums.phpfreaks.com/topic/123542-file-zipping-using-recursiveiteratoriterator/#findComment-638060 Share on other sites More sharing options...
random1 Posted September 11, 2008 Author Share Posted September 11, 2008 Hmm... I found this: http://us.php.net/manual/en/function.ziparchive-addfile.php Comment at bottom by Andreas R. newsgroups2005 at geekmail de Currently the number of files that can be added using addFile to the ZIP archive (until it is closed) is limited by file descriptors limit. How can I take this into account in the code? Link to comment https://forums.phpfreaks.com/topic/123542-file-zipping-using-recursiveiteratoriterator/#findComment-638765 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.