Packaging features ~ easy and convenient! The compression ratio is a little bit worse than WinRAR, but it doesn't matter. After all, only package to download
Save yourself to go to the server to pack the site if the server is not their own more trouble to let others help lay the bag
Copy CodeThe code is as follows:
PHP compressed directory into ZIP package
Author: Xiao Feng
$button =$_post[' button '];
if ($button = = "Start packing")
{
$zip = new Ziparchive ();
$filename = "./". Date ("y-m-d"). " _ ". MD5 (Time ())." _jackfeng.zip ";
if ($zip->open ($filename, ziparchive::create)!==true) {
Exit ("Cannot create < $filename >\n");
}
$files = Listdir ();
foreach ($files as $path)
{
$zip->addfile ($path, Str_replace ("./", "", str_replace ("\ \", "/", $path)));
}
echo "Compression complete, total compression:". $zip->numfiles. "A file \ n";
$zip->close ();
}
Function listdir ($start _dir= '. ') {
$files = Array ();
if (Is_dir ($start _dir)) {
$fh = Opendir ($start _dir);
while (($file = Readdir ($FH))!== false) {
if (strcmp ($file, '. ') ==0 | | strcmp ($file, ' ... ') ==0) continue;
$filepath = $start _dir. '/' . $file;
if (Is_dir ($filepath))
$files = Array_merge ($files, Listdir ($filepath));
Else
Array_push ($files, $filepath);
}
Closedir ($FH);
} else {
$files = false;
}
return $files;
}
?>
<title>Online packaging tools</title>
http://www.bkjia.com/PHPjc/319366.html www.bkjia.com true http://www.bkjia.com/PHPjc/319366.html techarticle Packaging features ~ easy and convenient! The compression ratio is a little bit worse than the WinRAR, but it doesn't matter. After all, only package to do the download save yourself to the server to pack the site if the server is not self ...