Home » PHP Code »

1

Use the following code to unzip the zip file using php code:

<?php
function unzip($location,$newLocation){
if(exec(“unzip $location”,$arr)){
mkdir($newLocation);
chmod($newLocation,0777);
for($i = 1;$i< count($arr);$i++){
$file = trim(preg_replace(“~inflating: ~”,”",$arr[$i]));
chmod($file,0777);
copy($file,$newLocation.’/’.$file);
//
unlink($file);
}
return TRUE;
}else{
return FALSE;
}
}
?>
//Use the code as following:
<?php

if(unzip(‘zip-file.zip’,'unZipFile’))
echo ‘Success!’;
else
echo ‘Error’;
?>

Hope that this will be useful.


Related Posts

    We get the address by latitude and longitude -using php codeMulti-language support for web application with MySql and PHPView more option in simple phpPHP Charts with using Google API

 

1 Comment

  1. If you interested to write an article on 9lessons as a guest author plz send the document.

Leave a Reply