Unzipping files zipped under unix

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
coolprgrmr
Forum Newbie
Posts: 1
Joined: Mon Nov 20, 2006 12:28 pm

Unzipping files zipped under unix

Post by coolprgrmr »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi,
I have a small script which zips files and makes it available for being downloaded to clients computer.
The snipped of the code which zips the files and makes if available for download is

Code: Select all

<?
$zfiles = "file1 file2 file3 file4 ...  file50" =>files to be downloaded

       header('Content-type: application/zip');
      header('Content-Disposition: attachment;filename=images.zip');
         $zipfiles = "/usr/local/bin/zip  -  ". $zfiles;
         $handle = popen ($zipfiles, 'r');

fpassthru($handle);
?>
The above code works fine and I can unzip the files under unix with unzip command however when I try to unzip the images.zip file under windows using winzip, I keep getting the following error message
start of central directory not found, zip file corrupt.
Appreciate if anybody can help me in this regards. Is there any option which needs to be set while zipping the files to make the zip file compatible with windows.

Thanks,


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

You could look into using a more cross platform zipping method such as the class(es) in Code Snippets that were posted by redmonkey.

viewtopic.php?t=29027
and
viewtopic.php?t=29066
Post Reply