PHP online packaging program source code_PHP tutorial

WBOY
Release: 2016-07-21 15:50:34
Original
1306 people have browsed it

Realize the packaging function ~ easy and convenient! Although the compression ratio is a little worse than winrar, it doesn't matter. After all, it is only packaged for downloading
You save yourself from going to the server to package the site. If the server is not your own, it will be more troublesome. Ask others to help package the package

Copy code The code is as follows:

//php compress the directory into a zip package
//Author: Xiao Feng
$button=$_POST['button']; 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") ;                                                                                      place("./", "",str_replace("\","/",$path)));                                                                                                
$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);
} el se {
$files = false;
}
return $files;
}
?>
                                                          ="text/html; charset=gb2312">                                                                     🎜>                                                                                                        gt; < ;input type="submit" name="button" value="Start Packing" />


Depending on the size of the file, it may take a long time. After the packaging is completed, the compressed package will be stored in the directory of the site to be packaged, named with packing time + random string of variable length + jackfeng.zip, please Log in to ftp and download.

                                                            



http://www.bkjia.com/PHPjc/319366.html
www.bkjia.com

truehttp: //www.bkjia.com/PHPjc/319366.htmlTechArticleAchieve packaging function ~ easy and convenient! Although the compression ratio is a little worse than winrar, it doesn't matter. After all, it is only packaged for downloading. It saves you having to go to the server to package the site if the server is not automatically...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template