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