Reputation: 4221
I have a folder with files, and at the click of a button from an application, I would like to create a zipped version of the folder. I understand that it's possible to create a tar.gz version on a UNIX system by passing in the command exec(tar -cvf foldername destination_filename
).
Question: Is it possible to create a zipped file on a UNIX system? If it is possible, what's the logic/command behind it?
Upvotes: 0
Views: 320
Reputation: 9252
Most *nix systems will support the following commnad:
zip -r destination_filename.zip foldername
Upvotes: 2
Reputation: 137272
You need to pass the -z
option to tar
to have it also zip the file:
tar -czf foo.tar.gz foo/
Make sure you are in a place that the webserver has write privileges. For example, you may need chdir into the parent folder of the folder you wish to zip, and then get a temp file name in /tmp
, and then create the command to zip to that temp file name.
It sounds like you have the rest figured out!
http://www.gnu.org/software/tar/manual/tar.html
Upvotes: 1
Reputation: 3461
Use php zip extension? http://www.php.net/manual/en/class.ziparchive.php And i guess you'll find useful classes from phpclasses too: http://www.phpclasses.org/search.html?words=zip&x=0&y=0&go_search=1
Upvotes: 1