Unzip a Zip File Using PHP


In Previous articles, we have learnt few operations on ZIP files using PHP and JavaScript. Most of the articles were about creating Zip files In this article, we will see how to unzip a ZIP archive using PHP.

For unzipping an archive, we will use unzip command of unix or linux server. See the sample code below.

Also Read:

Add this code in functions.php file.

function unzip($sourcelocation,$newLocation){
if(exec("unzip $sourcelocation",$arr)){
for($i = 1;$i< count($arr);$i++){
$file = trim(preg_replace("~inflating: ~","",$arr[$i]));
return true;
return false;

Now use this functions.php file whenever you want to use unzip function.

include 'functions.php';
echo 'Success!';
echo 'Error';

If you have any confusion, you can ask us via comments.

Tags: |

Deepanker Verma is the founder of Techlomedia. He is a tech blogger, developer and gadget freak.

Similar Articles


Leave a comment

Comment policy: We love comments and appreciate the time that readers spend to share ideas and give feedback. However, all comments are manually moderated and those deemed to be spam or solely promotional will be deleted.

2020 UseThisTip | Part of Techlomedia Internet Pvt Ltd Developed By Deepanker