Extract files and directories from ZIP file in php

Some, Control Panel has no facility to extract files from the ZIP file. So that following script is useful to extract or unzip the zip file using php code.

Here, we have to provide the path from where zip file will be taking for extracting purpose and also provide the path where to put extracted files and directories (data).

See the Following script.

$zipObj = new ZipArchive();    // create zip object
$files = $zipObj->open(‘unzip/test.zip’); // Open Zip Archive
		
if ($files == TRUE)
{
	$zipObj->extractTo(‘extracted/’); // Unzip or Extract Zip file to given Directory.
	$zipObj->close();
}
Posted in PHP. 1 Comment »

One Response to “Extract files and directories from ZIP file in php”

  1. nurse esthetician Says:

    I constantly spent my half an hour to read this
    website’s articles all the time along with a mug of coffee.


Speak Your Mind

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: