Read files in chunks to avoid memory limits when download_via_php is enabled. Fixes #2334.