add_data($filepath[, $data = NULL])
Parameters: |
|
---|---|
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.
Please login to continue.