[eluser]Unknown[/eluser]
Hi guys,
I'm writing a form page that requests contact details then allows a user to download a ZIP archive containing PDF documents, based on selections from a checkbox list. The ZIP file is creating and downloading fine, however when I open the file it comes back with the message 'Unexpected end of archive'.
Here's the code I'm using to generate the ZIP archive:
Code:
// Example of what form is passing to processing script.
$_POST['files'] = array(
'products',
'services'
);
$this->load->library('zip');
foreach ($_POST['files'] as $k => $v)
{
// Make sure file exists before archiving.
if (file_exists('/path/to/file/' . $v . '.pdf') === FALSE)
{
continue;
}
$this->zip->read_file('/path/to/file/' . $v . '.pdf');
}
$this->zip->download('archive.zip');
I also have noticed that the modified dates in the archive are weird (i.e. 21/09/30032 12:51) if that helps.
Any insight into what I'm doing wrong or a solution to this problem would be great.
Thanks in advance.