PHP implementation of the website file batch compression download function, _php tutorial

Source: Internet
Author: User
Tags ziparchive

PHP implementation of the Web site files bulk compression download function,


The PHP implementation of the file bulk compression package download, this process will be used to ziparchive this class, note that before using this class, Linux needs to turn on Zlib,windows to cancel the Php_zip.dll before the comments. A simple example of compressing a file into a zip format is given below. For specific usage, please consult the relevant PHP documentation.

<?php $filename = ' test.zip '; The resulting file name (with path) if (File_exists ($filename)) {   unlink ($filename);}//Regenerate the file $zip =new ziparchive (); if ($zip Open ($filename, ziparchive::create)!==true) {   exit (' cannot open file, or file creation failed ')} $datalist =array (' try.php ', ' Zip_ Class.php '); foreach ($datalist as $val) {   if (file_exists ($val)) {     $zip->addfile ($val);   }} $zip->close ();//Close If (!file_exists ($filename)) {   

The above is the PHP implementation of the file bulk compression package Download all content, we can also use PHP to invoke the Linux system shell script to achieve this function, this is a thought, I hope you can study.

http://www.bkjia.com/PHPjc/1065566.html www.bkjia.com true http://www.bkjia.com/PHPjc/1065566.html techarticle PHP Implementation of the Web site files bulk compression download function, the use of PHP implementation of the file bulk compression package download, the process will be used to ziparchive this class, note that before using the class, Li ...

  • 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.