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

孤街醉人 提交于 2019-11-30 01:23:38

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.

I have also get it worked by using this command

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

Bassam Essa
cd /home/public_html/site/upload/ && zip -r sub_upload.zip sub_upload/
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!