View Single Post
Old June 20th, 2008, 8:20 PM   #4 (permalink)
patrickb
the one who was
Super #1
 
patrickb's Avatar
 
Joined in Jul 2003
Lives in Memphis
1,967 posts
Gave thanks: 0
Thanked 3 times
Okis, I think there may be an issue here using the ZipArchive functions. Basically what I see in this code is first, it is always assumed that the file attachment is going to be a zip. Not sure of the content of the attachments you are dealing with, but that's a potential cause of this problem, and potential for a real headache in the future for sure.

The other thing I see is that there is no return value checking on the "$zip->extractTo('/stk/temp/');" and "$zip->close();" lines. Some return value checking here in the form of an if statement would be useful in tracking whether those two functions are successful. Replace those lines with something along this line:

Code:
if ($zip->extractTo('/stk/temp/')) {
	echo "Extraction ok";
} else {
	echo "Extraction failed";
}

if ($zip->close()) {
	echo "Closing ok";
} else {
	echo "Closing failed";
}
That alone should at least verify whether those two functions are successful which is critical in tracking the error.

Now the other twist, the extractTo function of ZipArchive will maintain the file structure of the zip archive, so if the zip had a file along the lines of "FOLDER/includedfile" then instead of writing 'includedfile' to your directory, it would write '/stk/tmp/FOLDER/includedfile'. Then the copy function would copy '/stk/tmp/FOLDER' to a file in the users directory. I am not sure of the behavior of the copy function when it is passed an actual directory as the filename, other than it may just copy the directory itself and it does not do any copying of the files in that directory. This would also explain the 1k file sizes as directories are always 1k in size on most *nix type OS's.

These are just some ideas for right now, I don't have my test bed server setup and no website as of right now to test on so I can't do any direct testing, but it should be something to get you started. Post back any findings or questions.
__________________
Patrick

Warnings: The program(s) might crash unexpectedly or behave otherwise strangely. (But of course, so do many commercial programs on Windows.) --www.gimp.org
patrickb is offline   Reply With Quote