user1885136 user1885136 - 29 days ago 4
Linux Question

How to Create zip file in PHP using shell command on linux server

this is the command that actually i want to run using PHP in Linux server.

shell_exec(" zip -r abc.doc xyz.doc > foo.zip ");


Using this command i script create damanged zip file, so can anyone help me to make it proper.

Answer

The syntax is incorrect. Try

zip foo abc.doc xyz.doc

or

zip -r foo abc.dox xyz.doc

depending upon whether you intend to replace the existing archive or not. See man zip for more.