[eluser]dawnerd[/eluser]
It is very possible and gave me much trouble when I first attempted it.
Code:
function _readfile_chunked($filename,$retbytes=true) {
$chunksize = 1*(1024*1024); // how many bytes per chunk
$buffer = '';
$cnt =0;
// $handle = fopen($filename, 'rb');
$handle = fopen($filename, 'rb');
if ($handle === false) {
return false;
}
while (!feof($handle)) {
$buffer = fread($handle, $chunksize);
echo $buffer;
ob_flush();
flush();
if ($retbytes) {
$cnt += strlen($buffer);
}
}
$status = fclose($handle);
if ($retbytes && $status) {
return $cnt; // return num. bytes delivered like readfile() does.
}
return $status;
}
That's the best way in case you have a larger pdf. As for the path, it is relative to the CI root. Meaning if it is below pub_html then you must use ../downloads/file.
In the class I supplied above, the first parameter is the path to the file with the filename at the end.
I hope this helped.