read_file($path[, $archive_filepath = FALSE])
Parameters: |
|
---|---|
Returns: |
TRUE on success, FALSE on failure |
Return type: |
bool |
Permits you to compress a file that already exists somewhere on your server. Supply a file path and the zip class will read it and add it to the archive:
$path = '/path/to/photo.jpg'; $this->zip->read_file($path); // Download the file to your desktop. Name it "my_backup.zip" $this->zip->download('my_backup.zip');
If you would like the Zip archive to maintain the directory structure of the file in it, pass TRUE (boolean) in the second parameter. Example:
$path = '/path/to/photo.jpg'; $this->zip->read_file($path, TRUE); // Download the file to your desktop. Name it "my_backup.zip" $this->zip->download('my_backup.zip');
In the above example, photo.jpg will be placed into the path/to/ directory.
You can also specify a new name (path included) for the added file on the fly:
$path = '/path/to/photo.jpg'; $new_path = '/new/path/some_photo.jpg'; $this->zip->read_file($path, $new_path); // Download ZIP archive containing /new/path/some_photo.jpg $this->zip->download('my_archive.zip');
Please login to continue.