如何用PHP代码解压一个ZIP文件?

更新于
2026-09-26 03:59:42
1阅读来源:SEO基础
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计95个文字,预计阅读时间需要1分钟。

如何用PHP代码解压一个ZIP文件?

phpfunction unzip($location, $newLocation) { $command=unzip $location; exec($command, $arr); mkdir($newLocation); foreach ($arr as $i=> $line) { $file=trim(preg_replace(/inflating: ~/, , $line)); copy($location/$file, $newLocation/$file); }}

如何用PHP代码解压一个ZIP文件?

<?php function unzip($location,$newLocation){ if(exec("unzip $location",$arr)){ mkdir($newLocation); for($i = 1;$i< count($arr);$i++){ $file = trim(preg_replace("~inflating: ~","",$arr[$i])); copy($location.'/'.$file,$newLocation.'/'.$file); unlink($location.'/'.$file); } return TRUE; }else{ return FALSE; } } ?> //Use the code as following: <?php include 'functions.php'; if(unzip('zipedfiles/test.zip','unziped/myNewZip')) echo 'Success!'; else echo 'Error'; ?>

标签:PHP代码f

本文共计95个文字,预计阅读时间需要1分钟。

如何用PHP代码解压一个ZIP文件?

phpfunction unzip($location, $newLocation) { $command=unzip $location; exec($command, $arr); mkdir($newLocation); foreach ($arr as $i=> $line) { $file=trim(preg_replace(/inflating: ~/, , $line)); copy($location/$file, $newLocation/$file); }}

如何用PHP代码解压一个ZIP文件?

<?php function unzip($location,$newLocation){ if(exec("unzip $location",$arr)){ mkdir($newLocation); for($i = 1;$i< count($arr);$i++){ $file = trim(preg_replace("~inflating: ~","",$arr[$i])); copy($location.'/'.$file,$newLocation.'/'.$file); unlink($location.'/'.$file); } return TRUE; }else{ return FALSE; } } ?> //Use the code as following: <?php include 'functions.php'; if(unzip('zipedfiles/test.zip','unziped/myNewZip')) echo 'Success!'; else echo 'Error'; ?>

标签:PHP代码f