A buddy to implement the online packaging tool PHP, and search for one on the internet, but unlike the requirements of the friend, his request is the page to carry out the variables passed over the file to be packaged and downloaded in the browser, but from the Internet to find this test under the feeling system is also good, the code is less, It's just a package for one directory file, and the summer blog will share a good code, the example code is as follows:
<?PHP$button=$_post[' button ']; if($button= = "Start packing") { $zip=Newziparchive (); $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. "Files \ n"; $zip-Close (); } FunctionListdir ($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"> <HTML> <Head> <title>Online packaging tools</title> <Metahttp-equiv= "Content-type"content= "text/html; charset=gb2312"> </Head> <Body> <formname= "Form1"Method= "POST"Action=""> <HRsize= "1"> <H3><ahref="?">Online packaging tools</a></H3> <P> <inputtype= "Submit"name= "button"value= "Start packing" /></P> <P>Note: The point starts packing, after that, is patiently waits for the packing to complete, depending on the website file how many, the time may be very long. After packaging is complete, the compressed package is stored in the site directory to be packaged to<spanstyle= ' color:red; '>Packing time + indefinite length random string +jackfeng.zip</span>So named, please login FTP after downloading.</P> </form> </Body> </HTML>
Article Source: https://www.xiariboke.com/codes/1595.html
PHP Online Packaging tools