dongmeirang4679 2016-05-11 13: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 13: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条)

报告相同问题?

悬赏问题

  • ¥15 计算二重积分∫∫e^(x+y)dxdy,其中0≤x≤1,0≤y≤1,试分别用复合辛普森公式(取n=4)以及高斯求积公式(取n=4)计算积分 给出matlab程序
  • ¥15 opencv 无法读取视频
  • ¥15 用matlab 实现通信仿真
  • ¥15 按键修改电子时钟,C51单片机
  • ¥60 Java中实现如何实现张量类,并用于图像处理(不运用其他科学计算库和图像处理库))
  • ¥20 5037端口被adb自己占了
  • ¥15 python:excel数据写入多个对应word文档
  • ¥60 全一数分解素因子和素数循环节位数
  • ¥15 ffmpeg如何安装到虚拟环境
  • ¥188 寻找能做王者评分提取的