extract files from zip

by Guna 2012-07-23 18:49:07

This function uses php zip extentions to extract files from zip file. You've to provide two parameters to
this function. 1) A valid zip file 2) destination the files to be extracted


function Extract_zip($source, $destination)
{
$zip = new ZipArchive(); // Call object of ZipArchive
if ($zip->open($source) === TRUE)// Open Compressed.zip for extracting all files
{
$destination = str_replace('\\', '/', realpath($destination));
// Will extract all files from master.zip to given path.
$zip->extractTo($destination);
$zip->close();
}
}
Extract_zip("sample.zip", '/home/guna/link/');

Tagged in:

784
like
0
dislike
0
mail
flag

You must LOGIN to add comments