PHP Online Packaging tools

Source: Internet
Author: User
Tags php online strcmp ziparchive

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

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.