To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
PHPBuilder.com  
 

 

Go Back   PHPBuilder.com > PHP Help > Coding

Coding Help with PHP coding

Reply
 
Thread Tools Rate Thread Display Modes
Old 03-09-2006, 03:40 PM   #1
thewhitenoise
Junior Member
 
Join Date: Mar 2006
Posts: 1
Question zip_open function returning integer

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.

PHP Code:
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);
    }
}
thewhitenoise is offline   Reply With Quote
Old 07-03-2006, 12:32 PM   #2
romrick
Junior Member
 
Join Date: Jul 2006
Posts: 1
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.
romrick is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 07:32 PM.






Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.