PHP Extract Zip File


PHP Extract Zip File. This article is a continuation of previous articles php create zip file. Once we can create zip file with php, then we will extract the zip file. If you have not to read php create zip file, please read it.

Ok, we go to extract the zip file with php, we begin by making extractzip.php. Fill the file with the following php script :

PHP Extract Zip File script

<?php
$zip = new ZipArchive; 
//tes.zip is the file to extract  
if ($zip-&gt;open('test.zip') === TRUE) {
	$zip-&gt;extractTo(getcwd());
	$zip-&gt;close(); echo 'ok';
	}
else {
	echo 'failed';
	}
?>

Upload extractzip.php and test.zip to your web directory, then open up extractzip.php with your web browser. Look at your web directory, you will see the test.zip have been extracted. :D
Download

Published by

Tinggalkan Balasan

Alamat email Anda tidak akan dipublikasikan. Ruas yang wajib ditandai *