You may wish to generate ZIP folders from your application and force a download for your users; for example, if you have a group of files, such as a press pack, which you wish to be kept together, or a set of CSV files. Saving them into a ZIP file and allowing a download is a great way to do this.
We're going to create a new file:
/path/to/codeigniter/application/controllers/zip.php
And copy the following code into it:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); class Zip extends CI_Controller { function __construct() { parent::__construct(); $this->load->helper('form'); $this->load->helper('url'); $this->load->library('zip'); } public function index() { redirect('zip/zipme'); } public function zipme() { $file_name = '/path/to/zip/tozip.txt'; // Create some data for the file $data = 'This is a string of text which we will use to write...