PHP Online Packaging _ Support subdirectory _php Tips
Source: Internet
Author: User
The program uses PHP zip extension, if the server support, it can be used ^_^, the resulting zip compression package can be used to extract the WinRAR, of course, can also use PHP to extract. Decompression over a period of time again released.
<?php
$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. "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;
}
?>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >
<title> Online Packaging Tools </title>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<body>
<form name= "Form1" method= "Post" action= "" >
<HR size= "1" >
<P> <input type= "Submit" name= "button" value= "Start packing"/></p>
<P> Note: The point starts packing, after that, is patiently waits for the packing completes, according to the website document how many, may need the time to be very long. After the package is complete, the package will be stored in the directory to be packaged to <span style= ' color:red; > Packing time + indefinite length random string +jackfeng.zip</span> This name, please login ftp download. </P>
</form>
</body>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service