Heim  >  Artikel  >  Backend-Entwicklung  >  PHP解压ZIP文件

PHP解压ZIP文件

WBOY
WBOYOriginal
2016-07-25 08:42:46887Durchsuche
  1. function unzip($location,$newLocation)
  2. {
  3. if(exec("unzip $location",$arr)){
  4. mkdir($newLocation);
  5. for($i = 1;$i $file = trim(preg_replace("~inflating: ~","",$arr[$i]));
  6. copy($location.'/'.$file,$newLocation.'/'.$file);
  7. unlink($location.'/'.$file);
  8. }
  9. return TRUE;
  10. }else{
  11. return FALSE;
  12. }
  13. }
复制代码

用法:

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

PHP, ZIP


Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn