Home » File Formats » File_Archive » Bug #5024
Weird behavior with dynamic zip file containing multiple files.
Details
| Submitted | 2005-08-08 13:56 UTC |
|---|---|
| From | rsg at ll dot mit dot edu |
| Status | Bogus |
| Package | File_Archive |
| PHP Version | 4.3.10 |
| OS | Gentoo Linux |
| Roadmaps | (Not assigned) |
Comments
[2005-08-08 13:56 UTC] rsg at ll dot mit dot edu
Description:
------------
Hi,
I am attempting to implemented a dynamically created Zip file containing a number of files; the zip is to be sent automatically as a download. I started with the tutorial for "Dynamically Created", and added the output writer:
<?php
require_once "File/Archive.php";
$dest = File_Archive::toArchive("foo.zip", File_Archive::toOutput());
$dest->newFile("even.txt");
for($i=0; $i<100; $i++)
$dest->writeData((2*$i)."\n");
$dest->newFile("odd.txt");
for($i=0; $i<100; $i++)
$dest->writeData((2*$i+1)."\n");
$dest->close();
?>
This worked just fine. However, when I use the exact same method in my app, I get an apparently fine archive. I can indeed extract the last file in it, but if I try to extract or view the others, I get the following message from WinZip:
"Extracting to "C:\Documents and Settings\rov9297\Local Settings\Temp\"
Use Path: no Overlay Files: yes
warning [C:\Documents and Settings\rov9297\Local Settings\Temp\-tmp-foo-13.zip]: extra 37594 bytes at beginning or within Zip file (attempting to process anyway)
Error in file #1: bad Zip file offset (Error local header signature not found): 0
(attempting to re-compensate)
Error in file #1: bad Zip file offset (Error local header signature not found): 0"
The number (37594) is odd for two reasons: First, the two files are about 3k and 4k bytes long, and second, it is always 37594, regardless of how many files are in the archive, or how big they are.
Any ideas? Oh, I have 1.5.2 of File_Archive, on PHP 4.3.10, running on Gentoo Linux...
Thanks!
-Bob
[2005-08-08 14:26 UTC] rsg at ll dot mit dot edu
Okay, it seems I have narrowed down the problem, but I can't understand it still. The following is the line that is suspect:
$dzip = File_Archive::toArchive("/tmp/fool.zip", File_Archive::toOutput());
The result of an example with two files (about 3K and 4K in size) is a 42K file that consists of 37594 bytes of garbage, followed by the first real file, followed by the second file; only the second file is accessible, however. If I change the "toOutput()" to "toFiles()", the zip file created is the proper size, and both files are read properly. However, the zip file is still on the server. Don't know what's going on, but is my call somehow bad?
[2005-08-16 14:20 UTC] rsg at ll dot mit dot edu
Hi Vincent,
Yeah, your test code works fine for me - in fact, that is exactly how I started it!
More experimenting shows some funny things, but nothing I can find to help pin down a concrete example that can reproduce it. It seems sometimes there will be only one good file, sometimes the last two, etc. On the one hand, I can't find any problems with my code, but on the other, I can't prove it isn't my code! Given that I can't prove it a bug, and I have an acceptable work-around (generate the file on the server, which works, then serve the resulting .zip file), I think it is okay to close this as Bogus, if you would like. I don't want to waste any more of your time on something even I'm not convinced is a bug...
[2005-08-16 14:22 UTC] rsg at ll dot mit dot edu
Can't prove it, so close it as bogus. Still, being in the bug-base, hopefully if others hit the same issue, this might prove helpful. If not, and it is truly Bogus, then my apologies...