How to Extract or Unzip files from a .zip file using PHP

Here is the simple code which will extract a zip file. Here we are using pclzip.lib file to extract files. You no need to install any other library to your server.

First download pclzip.lib file.

Now use the below code to extract your zip file.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<html>
<head><title>unzip | studentprojects.in</title>
</head>
<body>
<?php	
require_once('pclzip.lib.php'); 
$zipfile = new PclZip('filename.zip');
if ($zipfile -> extract() == 0) {
	echo 'Error : ' . $zipfile -> errorInfo(true);
}else{
	echo 'File Extracted!';
} 
?>
</body>
</html>
Editorial Team
Editorial Team

We are a group of young techies trying to provide the best study material for all Electronic and Computer science students. We are publishing Microcontroller projects, Basic Electronics, Digital Electronics, Computer projects and also c/c++, java programs.

Leave a Reply

Your email address will not be published. Required fields are marked *

Get the latest updates on your inbox

Be the first to receive the latest updates from Codesdoc by signing up to our email subscription.

    StudentProjects.in