Click to See Complete Forum and Search --> : zip_open function returning integer


thewhitenoise
03-09-2006, 02:40 PM
I've been working on a script to download a zip file from an ftp server and unzip the contents into a folder. I'm able to get everything from the ftp folder and save it locally with no problems, but I cannot get it unzipped.

I spent some time looking through the php manual on http://php.net , but none of the functions that other users had provided have worked. Failing that, I wrote a simple bit of code from scratch that should do what I need, but I keep getting an error to the tune of:

PHP Warning: zip_read() expects parameter 1 to be resource, integer given in c:\Inetpub\wwwroot\gamls\listing_download.php on line 139

I'm confused as to why it's not returning a resource, and instead returning an integer. I echoed the value of the variable which should hold the resource id, and I just keep getting "11" as the value.

Couldn't find much about it on php.net or through google. Is there sometime terribly obvious I'm missing that I haven't thought of yet? Yes, the file is there. I'm using an absolute path. IIS has permissions. The zip extension is installed.

I'm running IIS 6.0 on a Windows Small Business 2003 server.

if ($zip = zip_open("c:\\gamls_data\\$filename.zip")) {
echo "\$zip = " . $zip . "<br />\n";
while($zip_entry = zip_read($zip)) {
if (zip_entry_open($zip, $zip_entry)) {
$buffer = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
$fp = fopen(zip_entry_name($zip_entry, "w"));
fwrite($fp, $buffer);
zip_entry_close($zip_entry);
}
zip_close($zip);
}
}

romrick
07-03-2006, 11:32 AM
I had the exact same problem and I was fairly certain I had setup everything properly. In my situation, I was handling zip uploads. After numerous failed tries, I decided to see if I could open a generic zip file in the main php folder. I didn't think it would work, but it worked perfectly. When I re-checked my original code, I had failed to specify the correct path (which happened to be windows temp...) -- I also did not give the full path -- and I had also neglected to grant the internet user (IUSR_MACHINENAME) access to that folder.

I see in your case that you have indeed specified the full path. My guess is that you may not have specified the permission for the folder correctly -- and failing that you should double check the path that is generated is indeed correct.