[eluser]easymind[/eluser]
In my previous post here I deleted this because I didn't know the force_download() helper function from CI. But CI wants you to put the data in a variable first. So maybe this still is interesting:
Code:
$filename = 'somefile.pdf';
$filepath = '/some/path/';
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // some day in the past to avoid cached files
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename={$filename}");
header("Content-Transfer-Encoding: binary");
readfile($filepath.$filename);
Readfile directly dumps the data. So maybe you won't get the problem of the memory limit in PHP. Otherwise you can read and dump a file part by part yourself with fopen wrappers...
Then again....
You have the file data in the db, so you probably have to put the data in a variable. If you want it that way for security I can advice you to put files in a folder outside your webroot and use the above code in a function to let people download the files and maybe do a user check first. This way you do not have direct urls to your files but still can have files that are bigger than 8mb (standard PHP memory limit size? or 16mb...don't know)