Forum Moderators: coopster

Message Too Old, No Replies

unzip - zip read problem

         

brnco

10:10 am on Sep 5, 2008 (gmt 0)

10+ Year Member



Hi,

just installed a zlib on IIS. The problem is when I upload some zipped file I always get a message like:

Warning: zip_read() expects parameter 1 to be resource...

I tried to use full path to the file etc but it still doesn't work.

Is it some bug or something like this?

Thanks in advance,

Brnco

PHP_Chimp

3:17 pm on Sep 5, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Are you calling zip_open on the file first?
You may also want to look at the user comment on the zip_read manual page, as you may find that sorts your problem.

brnco

7:36 am on Sep 8, 2008 (gmt 0)

10+ Year Member



Yes I call the function. It's correct - without warnings. But zip_read is a problem.

PHP_Chimp

6:03 pm on Sep 8, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Warning: zip_read() expects parameter 1 to be resource

This would suggest that your code looks something like:

$file = 'path/to/file.php';
zip_read($file);

This will not work as zip_read requires a resource as the parameter and the example above is providing a string.
You should have something like:

<?php
$zip = zip_open("test.zip");
if ($zip)
{
while ($zip_entry = zip_read($zip))
{
echo "<p>";
echo "Name: " . zip_entry_name($zip_entry) . "<br />";
if (zip_entry_open($zip, $zip_entry))
{
echo "File Contents:<br/>";
$contents = zip_entry_read($zip_entry);
echo "$contents<br />";
zip_entry_close($zip_entry);
}
echo "</p>";
}
zip_close($zip);
}
?>

Code stolen from w3schools [w3schools.com].
More example on the manual page [us.php.net]

You would be better using a complete file path as noted in the manual, not the relative one that I have used as an example.

You may want to post some of the code that you are using. As it is difficult to provide you with help when we dont know what the problem is...