当前位置:Gxlcms > PHP教程 > PHP解压ZIP文件

PHP解压ZIP文件

时间:2021-07-01 10:21:17 帮助过:22人阅读

  1. function unzip($location,$newLocation)
  2. {
  3. if(exec("unzip $location",$arr)){
  4. mkdir($newLocation);
  5. for($i = 1;$i< count($arr);$i++){
  6. $file = trim(preg_replace("~inflating: ~","",$arr[$i]));
  7. copy($location.'/'.$file,$newLocation.'/'.$file);
  8. unlink($location.'/'.$file);
  9. }
  10. return TRUE;
  11. }else{
  12. return FALSE;
  13. }
  14. }

用法:

  1. unzip('test.zip','unziped/test'); //File would be unzipped in unziped/test folder
  2. ?>

PHP, ZIP

人气教程排行