bug_php tutorial on Read_dir methods in CodeIgniter framework Zip code class

Source: Internet
Author: User
Tags codeigniter
The CodeIgniter framework of the compression decoding class, where the Read_dir method allows you to compress a server somewhere in the presence of a folder (and the files and subfolders inside it).

Provide a folder path, the Zip class will read it recursively and re-create the add to archive. All files under the path you provide will be compressed, including all subfolders.

For example:

$path = '/path/to/your/directory/'; $this->zip->read_dir ($path);

The default zip file saves the full folder path of the first parameter to a zip file. If you want to ignore the folder structure before the destination path, you can pass FALSE (Boolean) to the second parameter.

For example:

$path = '/path/to/your/directory/'; $this->zip->read_dir ($path, false);

This will create a ZIP file that includes "directory", where all subfolders are properly stored, but not included in the folder/path/to/your.

The official document only mentions two parameters, the source code actually set up three:

Read_dir ($path, $preserve _filepath = TRUE, $root _path = NULL)

In general, there are several ways to get the path inside the framework's running environment:

apppath– corresponds to the CodeIgniter root directory, i.e.application/
fcpath– corresponds to the disk partition root directory, which isD:\xxx\codeigniter 根目录\

When using Fcpath and other ways to obtain the directory absolute path, because the source processing in the path of the backslash, causing the front and back $root _path value inconsistent, the second parameter false setting will be invalid.

Reference: http://codeigniter.org.cn/user_guide/libraries/zip.html

http://www.bkjia.com/PHPjc/363823.html www.bkjia.com true http://www.bkjia.com/PHPjc/363823.html techarticle The CodeIgniter framework of the compression decoding class, where the Read_dir method allows you to compress a server somewhere in the presence of a folder (and the files and subfolders inside it). Provide a ...

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