unzip a zip file using php - Php

Unzip a Zip file

Snippet Code


  
Rate this page :
  [ 0 votes]

This function is used to unzip a zip file using php

<?php function unZip($urllocation,$newurlLocation){ if(exec("unzip $urllocation",$arr)){ mkdir($newurlLocation); for($i = 1;$i< count($arr);$i ){ $file = trim(preg_replace("~inflating: ~","",$arr[$i])); copy($urllocation.'/'.$file,$newurlLocation.'/'.$file); unlink($urllocation.'/'.$file); } return TRUE; }else{ return FALSE; } } if(unzip('zipfile/test.zip','unziped/myNewZip')) echo 'Unzipped!'; else echo 'Failed'; ?>

Tags


Ask Questions

Ask Question