Using the below PHP snippet you would be able to unzip a file on the fly.
Syntax
1
2
3
|
<?php
unzip('test.zip','unziped/test'); //File would be unzipped in unziped/test folder
?>
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
function unzip($location,$newLocation)
{
if(exec("unzip $location",$arr)){
mkdir($newLocation);
for($i = 1;$i< count($arr);$i++){
$file = trim(preg_replace("~inflating: ~","",$arr[$i]));
copy($location.'/'.$file,$newLocation.'/'.$file);
unlink($location.'/'.$file);
}
return TRUE;
}else{
return FALSE;
}
}
|
1
2
3
|
<?php
unzip('test.zip','unziped/test'); //File would be unzipped in unziped/test folder
?>
|
Hello Friends! I am Ramana a part time blogger from Hyderabad.
0 comments:
Post a Comment