Sometimes you want to extract the content of zip file online. So in this article I will tell you how to extract or unzip the content of zip file using php.
<?php
$zip = new ZipArchive;
if ($zip->open('test.zip') === TRUE) {
$zip->extractTo($_SERVER['DOCUMENT_ROOT']."/FOLDERPATH");
$zip->close();
echo 'ok';
} else {
echo 'failed';
}
?>
PHP Function :
// Function
function zip_extract($file, $extractPath) {
$zip = new ZipArchive;
$res = $zip->open($file);
if ($res === TRUE) {
$zip->extractTo($extractPath);
$zip->close();
return TRUE;
} else {
return FALSE;
}
}
As I always here, if you get into troubles, you can use the comment form or Our Facebook Page !
0 comments
Post a Comment
Thanks For Visit :)
Note: only a member of this blog may post a comment.