最新消息: 新版网站上线了!!!

php创建压缩文件rar zip gz格的文件

<?php

function uncompress($srcName, $dstName) {
$string = implode("", gzfile($srcName));
$fp = fopen($dstName, "w");
fwrite($fp, $string, strlen($string));
fclose($fp);
}

function compress($srcName, $dstName)
{
$fp = fopen($srcName, "r");
$data = fread ($fp, filesize($srcName));
fclose($fp);

$zp = gzopen($dstName, "w9");
gzwrite($zp, $data);
gzclose($zp);
}

//change to the names of your files
compress("date.php","test.zip");
uncompress("test.zip","date.php");
echo "创建成功<A href=test.zip>test.zip</a>";
?>

转载请注明:谷谷点程序 » php创建压缩文件rar zip gz格的文件