Kneel-Before-ZOD
Kneel-Before-ZOD

Reputation: 4221

Creating a zipped folder at the click of a button

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

Answers (3)

MrGlass
MrGlass

Reputation: 9252

Most *nix systems will support the following commnad:

zip -r destination_filename.zip foldername 

Upvotes: 2

gahooa
gahooa

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

Kristian
Kristian

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

Related Questions