|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-09-15 13:29 UTC] bartlewis at gmail dot com
Description: ------------ In my test cases this extensions sometimes failed and other times worked. After a bit of debugging it seems that 509 files is the tipping point. If you try to pack up file 510 it will fail every time. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 22 08:00:01 2025 UTC |
Also try: <?php $zip = new ZipArchive(); $filename = '8714.zip'; if($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) { exit("failed to open the archive\n"); } for ($i = 0; $i <10000; $i++) { $zip->addFromString('testfile' . sprintf('%03d', $i) . '.txt', 'This is a test string added.'); } $zip->close(); var_dump(sprintf('%03d', 0)); It works well here using the version available in 5.2, please try this script with your PHP and the latest snapshot for php 5.2I can't upgrade to php 5.2 immediately. I'll write back with results when I do. Your sample code worked fine on my php 5.1.2 and successfully created thousands of files in the zip. I modified your code slightly (included below) and again it dies when trying to add more than 508 files. When this script fails the $status is 12. <?php $zip = new ZipArchive(); $filename = '8714f.zip'; if($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) { exit("failed to open the archive\n"); } for ($i = 0; $i <510; $i++) { $zip->addFile('blank.htm', 'testfile'.$i.'.txt'); } $zip->close(); echo $zip->status; ?>ok, I'm 99.99% sure about the source of the bug. If you use an absolute path, it will work. This bug was due to some non crossplatform bahaviors on windows. Try: $zip->addFile(realpath('blank.htm'), 'testfile'.$i.'.txt'); This bug is fixed in CVS and in php 5.2. pecl4win should provide the latest version as well, I will verify later why it does not. By the way, you don't need to update your install to use the snapshot, just uncompress it somewhere and call php from the cmd line.Cool, never ran a snapshot from the comman line. Just popped my cherry. :) Thanks for the tip. OK, I tried your suggestion in the 5.2 snapshot and my php5.1.2. Both produced the same results. I tried both of these lines in my loop: $zip->addFile('D:\localhost\Inetpub\xp22\blank.htm', 'testfile'.$i.'.txt'); $zip->addFile(realpath('blank.htm'), 'testfile'.$i.'.txt'); If the loop runs 1-508 times the file is written correctly. 509+ loops and the zip fails with a status of 12.