PHP implementation of online packaging download function method

Source: Internet
Author: User
Tags php online ziparchive
This article mainly introduces the PHP online packaging download function implementation method, combined with the example form analysis of PHP package download implementation process and related considerations, the need for friends can refer to the following

Last night, in order to get this package download thing, the thing is burnt. There are a few problems, the first one is to start php_zip.dll problem. As long as the php.ini inside the extend_dir inside of the former ";" The number is removed. Restart IIS or Apache.

The problem is that the real php.ini of the system configuration is not always found.

PHP configuration Diagram

The second one is to tell you the path to the configuration document, just press to find it. I had a funny head and wasted a lot of time.

Once you've opened the Php_zip extension library, you're ready to start packing and downloading.

$filename = Date ("Ymdhis"), $zip = new ziparchive ();//Use this class, Linux need to turn on Zlib,windows to cancel Php_zip.dll before the comment $zip->open ($ FileName. ". Zip ", ziparchive::overwrite); $data is the number that is read from the database, foreach ($data as $val) {   $attachfile = "E:\BYSJ\BYSJ". $val [' fileaddr ']. $val [' filename ']; Write hard path, but it is recommended to use PHP environment variable   $attachfile =iconv ("UTF-8", "GBK", $attachfile);//transcoding, is the key to packaging Chinese documents   $zip->addfile ($ Attachfile, basename ($attachfile)); Press Stack} $zip->close ();//Close Header ("Content-type:text/html;charset=utf-8");//Set page number header ("Cache-control:public" Header ("Content-description:file Transfer"); header (' Content-disposition:attachment; Filename= '. BaseName ($ filename)); FileName header ("Content-type:application/zip"); Header in zip format ("content-transfer-encoding:binary"); Tell the browser that this is the header of the binary file (' content-length: '. FileSize ($filename)); Tell the browser that the file size @readfile ($filename. "). Zip ");

The above code basically can be implemented to download the document package, but also solve the Chinese document can not be packaged download problems.

Summary: The above is the entire content of this article, I hope to be able to help you learn.

Related Article

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.