32,000+ SUBSCRIBERS CAN'T GO WRONG !!!

phpans
GET TOP ARTICLES, SNIPPETS, SCRIPTS IN YOUR INBOX FOR FREE!

Delivered by GET EMAIL UPDATES FeedBurner
We always respect your privacy and take protecting it seriously.
We won't Spam You

Easy Way To Extract Zip File Using PHP

, 0,
Easy Way To Extract Zip File Using PHP
You already know that how to create Zip file using PHP. In our last article, we had discussed Easy Way To Create ZIP File Using PHP in this tutorial we are going to discuss Easy Way To Extract Zip File Using PHP. If you know about creating Zip file in PHP then you should about extracting Zip file in PHP. You can use this when you upload Zip file and extract in PHP on the server and you want to extract this, you can use this to manage your website manually. We have published Install WordPress Manually Using PHP article and we use Zip unzip snippet in this article. Now we publish a specific article about this because of a clear concept about PHP extract file extension. It's pretty easy to make. Are you ready to make PHP unzipper? Let's see how to do that.

How to extract Zip file using PHP?


We are going to use a little snippet to unzip zip files. the snippet is,
<?php
$zip = new ZipArchive;
$res = $zip->open($filename); // Your filename
if ($res === TRUE) {
$zip->extractTo('./');
$zip->close();
}
?>

That's all. so easy, isn't it? You can create a function to use it everywhere easily. I am writting an example about this. In this code snippet we use a function and we will know about unzipper full process. Create a function name as Unzip() and write down this code.
<?php
function Unzip($file)
{
$zip = new ZipArchive;
$res = $zip->open($file);
if ($res === TRUE) {
$zip->extractTo('./');
$zip->close();
}
}
?>

Think you have a zip file your server and you want to make this unzip by using this function. Then follow step like this,

you zip file name is icons.zip and you want extract this,
<?php
$file = 'icons.zip';
Unzip($file);
?>

If you use this code, thjis code will extract icons.zip file. Next we will discuss how to upload zip file and extract in php. I hope you understand this. If you have any question or comment about Extract Zip File Using PHP article please don't hesitate to do that, please comment your question in comment section.

Download PDF
Signup & Get $25 Free
Is this article helpful for you?





captcha

  • Connect
  •       
Top
Create an free account and start learning & sharing! Sign Up