Hi!
As I can see from download_helper.php, CodeIgniter uses the classic combination of fopen and fread functions to achieve the reading of a file, if a path is provided to force_download helper function.
The only problem about this combination is that fread uses a hardcoded value for chunk size: 1048576 (1MB). This may be a memory usage problem on high-load applications developed with CodeIgniter (even on a dedicated server), and can be avoided by using PHP's function readfile, which is handling the reading according to server status and settings. As you can see from official docs, it shouldn't create any memory problems, even on big files.
To achieve this, from /system/helpers/download_helper.php lines 124-127 should be removed and 150-153 should be replaced with:
Hope this helps!
As I can see from download_helper.php, CodeIgniter uses the classic combination of fopen and fread functions to achieve the reading of a file, if a path is provided to force_download helper function.
The only problem about this combination is that fread uses a hardcoded value for chunk size: 1048576 (1MB). This may be a memory usage problem on high-load applications developed with CodeIgniter (even on a dedicated server), and can be avoided by using PHP's function readfile, which is handling the reading according to server status and settings. As you can see from official docs, it shouldn't create any memory problems, even on big files.
To achieve this, from /system/helpers/download_helper.php lines 124-127 should be removed and 150-153 should be replaced with:
PHP Code:
if (@readfile($filepath) === FALSE)
{
return;
}
Hope this helps!