|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-10-23 09:13 UTC] lajbr at seznam dot cz
Description:
------------
I found a serious problem on PHP 5.1.6 (5.1.4 too). I try to read content of .ZIP file (part of code is added below). I open an existing ZIP file and I want to read its content. But Warning message with following text is appeared (text is added below). The same problem occured when I use function zip_close(). As the result nothing is happened (no content from ZIP file is readed). When I go back to PHP version 5.0.5 then all works fine.
Reproduce code:
---------------
function ziplist($zipfile){
$retval = array();
if ($sourcezip = @zip_open($zipfile)) {
while ($zip_entry = zip_read($sourcezip)) {
array_push($retval,array('filename' => zip_entry_name($zip_entry),
'filesize' => zip_entry_filesize($zip_entry)));
}
zip_close($sourcezip);
} else return false;
return $retval;
}
Expected result:
----------------
Warning: zip_read() expects parameter 1 to be resource, integer given in C:\Inetpub\wwwroot\epo\include\function.php on line 439
Warning: zip_close() expects parameter 1 to be resource, integer given in C:\Inetpub\wwwroot\epo\include\function.php on line 443
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 23 10:00:01 2025 UTC |
You are doing something wrong in your script. I tried using 5.1.6, 5.2.0, 6.0 and with the latest pecl4win dll using this script: $zipfile = 'bug39231.zip'; if ($sourcezip = zip_open($zipfile)) { while ($zip_entry = zip_read($sourcezip)) { echo 'filename: '. zip_entry_name($zip_entry) . " "; echo 'filesize: '. zip_entry_filesize($zip_entry) . "\n"; } zip_close($sourcezip); } else { echo "Cannot open zip"; } C:\php-5.1.6>php.exe bug39231.php filename: result.htm filesize: 55457 filename: test.zip filesize: 131347 filename: ziptest.php filesize: 599 It works like a charm (and as expected). Be sure to load the correct php_zip.dll or to have restarted your server after a dll update.