>  기사  >  백엔드 개발  >  Unzip一个Zip文件的PHP代码

Unzip一个Zip文件的PHP代码

WBOY
WBOY원래의
2016-07-25 08:42:48804검색
  1. function unzip($location,$newLocation){
  2. if(exec("unzip $location",$arr)){
  3. mkdir($newLocation);
  4. for($i = 1;$i $file = trim(preg_replace("~inflating: ~","",$arr[$i]));
  5. copy($location.'/'.$file,$newLocation.'/'.$file);
  6. unlink($location.'/'.$file);
  7. }
  8. return TRUE;
  9. }else{
  10. return FALSE;
  11. }
  12. }
  13. ?>
  14. //Use the code as following:
  15. include 'functions.php';
  16. if(unzip('zipedfiles/test.zip','unziped/myNewZip'))
  17. echo 'Success!';
  18. else
  19. echo 'Error';
  20. ?>
复制代码

Unzip, Zip, PHP


성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.