RT
Ubuntu 10.04
zip 3.0 (July 5th 2008)PHP脚本调用zip压缩程序
$ZipCommand = "zip -q -D -r -9 ".$TempZip."  ".$LocalPath."  1>/dev/null 2>/dev/null";
system($ZipCommand);因为PHP脚本所在的路径为/var/www/*/
与$LocalPath对应的路径相差很远。查zip的manual得知:
Recursion:
  -r        recurse paths, include files in subdirs:  zip -r a path path ...
  -R        recurse current dir and match patterns:   zip -R a ptn ptn ...
  Use -i and -x with either to include or exclude paths
  Path root in archive starts at current dir, so if /a/b/c/file and
   current dir is /a/b, 'zip -r archive .' puts c/file in archive现在的理解是,必须在调用zip压缩程序之前给zip指定工作目录(current dir),这样才能添加相对路径。
如果想不添加路径,还没有想到合适的方法。如果zip无法实现,我就只能换其他压缩程序了。忘大家指点一二。

解决方案 »

  1.   

    为什么不下载一个php的类呢,很好用的……
      

  2.   


    还从来没有尝试用过PHP的类。我是初学者,让大家见笑了。
      

  3.   

    直接用php的zip压缩吧php的zip压缩:ziparchive
      

  4.   


    兄弟有些误解我的意思了。我只是想把制作的压缩文件zip包里面的全路径给去掉。刚刚看了兄弟建议的那个类,貌似也没有发现对应的选项。