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);
}
}