Bug_PHP tutorial for the read_dir method in the Zip encoding class of Codeigniter framework-php Tutorial

Source: Internet
Author: User
The bug of the read_dir method in the Zip encoding class of the Codeigniter framework. The compression and decoding class of the Codeigniter framework. the read_dir method allows you to compress a folder (as well as files and subfolders) that exists somewhere on the server ). Provides a compression and decoding class for the Codeigniter framework. the read_dir method allows you to compress a folder (as well as files and subfolders) that exists somewhere on the server ).

Provides a folder path. the zip class recursively reads it and creates it and adds it to the archive. All files under the path you provided will be compressed, including all subfolders.

For example:

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

By default, the full folder path of the first parameter is saved to the Zip file. If you want to ignore the folder structure before the target 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 including "directory". all subfolders are properly saved in it, but do not include this folder/path/to/your.

The official document only mentions two parameters. in the source code, three parameters are set:

read_dir($path, $preserve_filepath = TRUE, $root_path = NULL)

Generally, there are several methods to obtain the path within the framework runtime environment:

APPPATH-corresponds to the root directory of Codeigniter, that isapplication/
FCPATH-the root directory of the corresponding disk partition, that isD: \ xxx \ codeigniter root directory \

When you use methods such as FCPATH to obtain the absolute directory path, because the source code processes the backslash in the path, resulting in inconsistent values of $ root_path before and after, the second parameter false is invalid.

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

The compression decoding class of the http://www.bkjia.com/PHPjc/363823.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/363823.htmlTechArticleCodeigniter framework, where the read_dir method allows you to compress a folder that exists somewhere on a server (and the files and subfolders in it ). Provide...

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.