amakaram
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_clie nt/' '--with-imap-ssl=/usr' '--with-jpeg-dir=/usr' '--with-kerberos' '--with-libdir=lib64' '--with-libxml-dir=/opt/xm l2/' '--with-mcrypt=/opt/libmcr ypt/' '--with-mysql=/usr' '--with-mysql-sock=/var/li b/mysql/my sql.sock' '--with-openssl=/usr' '--with-openssl-dir=/usr' '--with-pcre-regex=/opt/pc re' '--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","file 1.jpg");
$zip->addFile("Penguins.jp g","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
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/
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.
$zip->addFile("Penguins.jp
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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["CurrentFileNa me"], 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
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["CurrentFileNa
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
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
ASKER
Well thank you.
Your responses were correct... but the problem *embarrassed smile* was mine!
Will delete shortly.
Your responses were correct... but the problem *embarrassed smile* was mine!
Will delete shortly.
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.