CI_Zip::add_data()

add_data($filepath[, $data = NULL])

Parameters:
  • $filepath (mixed) – A single file path or an array of file => data pairs
  • $data (array) – File contents (ignored if $filepath is an array)
Return type:

void

Adds data to the Zip archive. Can work both in single and multiple files mode.

When adding a single file, the first parameter must contain the name you would like given to the file and the second must contain the file contents:

$name = 'mydata1.txt';
$data = 'A Data String!';
$this->zip->add_data($name, $data);

$name = 'mydata2.txt';
$data = 'Another Data String!';
$this->zip->add_data($name, $data);

When adding multiple files, the first parameter must contain file => contents pairs and the second parameter is ignored:

$data = array(
        'mydata1.txt' => 'A Data String!',
        'mydata2.txt' => 'Another Data String!'
);

$this->zip->add_data($data);

If you would like your compressed data organized into sub-directories, simply include the path as part of the filename(s):

$name = 'personal/my_bio.txt';
$data = 'I was born in an elevator...';

$this->zip->add_data($name, $data);

The above example will place my_bio.txt inside a folder called personal.

doc_CodeIgniter
2016-10-15 16:32:08
Comments
Leave a Comment

Please login to continue.