Command to zip a directory using a specific directory as the root

前端 未结 3 1834
小鲜肉
小鲜肉 2020-12-25 11:34

I\'m writing a PHP script that downloads a series of generated files (using wget) into a directory, and then zips then up, using the zip command.

相关标签:
3条回答
  • 2020-12-25 12:08

    I have also get it worked by using this command

    exec('cd '.$_SERVER['DOCUMENT_ROOT'].' && zip -r com.zip "./"');

    0 讨论(0)
  • 2020-12-25 12:14

    I don't think zip has a flag to do that. I think the only way is something like:

    cd /var/www/oraviewer/rgn_download/download/ && \
       zip -r fcst_20100318_0319.zip fcst_20100318_0319
    

    (The backslash is just for clarity, you can remove it and put everything on one line.)

    Since PHP is executing the command in a subshell, it won't change your current directory.

    0 讨论(0)
  • 2020-12-25 12:31
    cd /home/public_html/site/upload/ && zip -r sub_upload.zip sub_upload/
    
    0 讨论(0)
提交回复
热议问题