Link to home
Start Free TrialLog in
Avatar of amakaram
amakaramFlag for Afghanistan

asked on

PHP ZipArchive() creates corrupt zip file

I have upgraded the server and since found that my zip is no longer working.

I currently am using: Apache 2.2.22 , PHP 5.3.10

Configure Command
'./configure' '--disable-fileinfo' '--disable-pdo' '--enable-bcmath' '--enable-calendar' '--enable-ftp' '--enable-gd-native-ttf' '--enable-libxml' '--enable-magic-quotes' '--enable-mbstring' '--enable-sockets' '--enable-zip' '--prefix=/usr' '--with-curl=/opt/curlssl/' '--with-curlwrappers' '--with-freetype-dir=/usr' '--with-gd' '--with-gettext' '--with-imap=/opt/php_with_imap_client/' '--with-imap-ssl=/usr' '--with-jpeg-dir=/usr' '--with-kerberos' '--with-libdir=lib64' '--with-libxml-dir=/opt/xml2/' '--with-mcrypt=/opt/libmcrypt/' '--with-mysql=/usr' '--with-mysql-sock=/var/lib/mysql/mysql.sock' '--with-openssl=/usr' '--with-openssl-dir=/usr' '--with-pcre-regex=/opt/pcre' '--with-pic' '--with-png-dir=/usr' '--with-xpm-dir=/usr' '--with-zlib' '--with-zlib-dir=/usr'


A simple script:

eg:
$zip = new ZipArchive();
$filename = "test112.zip";

if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) {
    exit("cannot open <$filename>\n");
}

$zip->addFile("Lighthouse.jpg","file1.jpg");
$zip->addFile("Penguins.jpg","file2.jpg");

echo "numfiles: " . $zip->numFiles . "\n";
echo "status:" . $zip->status . "\n";
$zip->close();

------------
(using all: Windows 7 zip, WinZip, WinRAR)

The zip file opens and the filesize looks ok in the two files, but when I open the images, it says they are corrupt.

I have tried both ZipArchive and also pclZipLib... both work with the same results.

Thanks
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

I am also using PHP 5.3.10.  Here is my ZIP information:
Zip       enabled
Extension Version       $Id: php_zip.c 321634 2012-01-01 13:15:04Z felipe $
Zip version       1.9.1
Libzip version       0.9.0

If you will post the example files here I will be glad to try them on my server.
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of amakaram

ASKER

Well Ray_Paseur, I have good news...

As I was getting the script and the images I was testing with, this EE uploader was failing them... upon closer look, the images were corrupt on the server... they originally were ftp'd from one server to the other and I guess I did not check the originals. (cant really believe that, but have no proof to the contrary)

Of course this was a small clip from a larger sript and I went back to the section of the script that moves the files in the first place... updated FTP_ASCII with FTI_BINARY and it worked.

...(ftp_fget($conn_id, $handle, $FilesMyrow["CurrentFileName"], FTP_BINARY, 0)...

Again, not sure why this would change on the new server... they have been ASCII for the last 2 years.

Let me know what you would like to do with points...

Thanks for your help!
Lighthouse.jpg
Penguins.jpg
Glad to hear that.  I tested with your image files and got the same result as before - WinRaR did a fine job.

Since it's not a ZIP related issue, I suggest you delete the question.  Not worried about the points - I have enough points to orbit Saturn.

All the best, ~Ray
Well thank you.

Your responses were correct... but the problem *embarrassed smile* was mine!

Will delete shortly.