Unzip Zip file using php

This is a quick tutorial to Unzip Zip file using php, Here I have created a quick function in php to extract zip file, Unzipping file is now very easy using php, In php there is a function called ZipArchive::extractTo, using this predefined function you can easily extract zip archive.



unzip-zip-file-php
Here is the function..

function.php

open($file) === TRUE) {
	    $zip->extractTo($location);
	    $zip->close();
	    return "Success";
	} else {
	    return 'failed';
	}
  }
?>

Now call this function anywhere you want and pass tow parameter, zip file and destination path where extracted file should be placed.




If you like this post please don’t forget to subscribe my public notebook for more useful stuff

Posted in PHP