dongmeirang4679 2016-05-11 05:35
浏览 103
已采纳

使用PHP压缩Linux服务器中的ZIP文件

I am trying to create a .zip file of a folder in linux.

First I go where the compressed folder is:

shell_exec('cd /var/www/vhosts/website/test/');

The folder test has the folder testzip which should be zipped and sent somewhere else:

shell_exec('zip a -r -tzip /var/www/vhosts/website/zip/save/testzip.zip /var/www/vhosts/website/test/testzip');

This should create testzip.zip. Somehow this doesn't work.

Could anyone help?

  • 写回答

2条回答 默认 最新

  • dowaw80220 2016-05-11 05:38
    关注

    Try with

    "zip -a -r ..."
    

    instead of

    "zip a -r ..."
    

    --- EDIT ---

    Reading the comment of Mark Adler, I realized that you're using zip with 7-zip parameters.

    So... are you sure that your zip is a link to 7z?

    Anyhow, I suggest you to avoid ambiguities: is your intention is use 7z, explicit it with

    "7z a -r -tzip ..."
    

    If you want call the zip executable, use a correct zip syntax.

    p.s.: sorry for my bad English

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部