[eluser]squarebones[/eluser]
This is an interesting problem. I wanted to do a simple zip download of my web directory from a shared hosting situation. Unfortunately, I got a weird error. So I tried reducing the download to one single file.
The config is such:
Code:
$config['backup_file'] = "/path/from/web/host/to/application/views/footer.php";
The following is the controller I created to read the file and affect the download:
Code:
class Backup_site extends Controller {
function Backup_site()
{
parent::Controller();
$this->load->library('zip');
}
function backup_itup()
{
$path = $this->config->item('backup_file');
$this->zip->read_file($path);
$this->zip->download('one_file.zip');
}
}
I confirmed that the zlib library is being loaded by my web host (compiled --with bzip2 and loading Zlib v1.2.3) and all seems well. By commenting out the $this->zip->download line, I at least get a blank page meaning that (with error reporting set at 4) the read_file is being performed, but if the script hits $this->zip->download('one_file.zip'); I get this error on my screen:
A PHP Error was encountered
Severity: Notice
Message: Only variables should be assigned by reference
Filename: libraries/Zip.php
Line Number: 328
That line of code is in the Zip library in this function:
Code:
/**
* Download
*
* @access public
* @param string the file name
* @param string the data to be encoded
* @return bool
*/
function download($filename = 'backup.zip')
{
if ( ! preg_match("|.+?\.zip$|", $filename))
{
$filename .= '.zip';
}
$zip_content =& $this->get_zip(); // This is the errant line that is throwing the error
$CI =& get_instance();
$CI->load->helper('download');
force_download($filename, $zip_content);
}
So, at this point, I have to give up on this library being at all useful in my situation. I can't even get it to download an empty zip archive (reported by another user as a bug), which would be something at least.
I don't know what this requires to function properly as the user guide lists no requirements for correct operation.
Should this be reported as a bug?