From fcae11a2484fc97b39fd8a75600be8c26ceb1c42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Luttringer?= Date: Thu, 15 Sep 2011 15:14:49 +0000 Subject: [PATCH] optimize memory consumption when downloading files --- include/videos.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/include/videos.php b/include/videos.php index 4e62158..d06cdd9 100644 --- a/include/videos.php +++ b/include/videos.php @@ -161,7 +161,14 @@ function getVideo() { header('Content-Transfer-Encoding: binary;'); header('Content-Length: ' . filesize($video["video_path"]).';'); flush(); - readfile($video["video_path"]); + //We now push by block of 10M to save memory consumption of readfile + //readfile($video["video_path"]); + $fd = fopen($video["video_path"], 'rb'); + while (!feof($fd)) { + $buf = fread($fd, 10485760); + echo $buf; + } + fclose($fd); } else { header("Status: 404 Not Found"); -- GitLab