Skip to content

Instantly share code, notes, and snippets.

@nqphuong
Last active October 1, 2015 12:26
Show Gist options
  • Save nqphuong/ad551d555899068adb7f to your computer and use it in GitHub Desktop.
Save nqphuong/ad551d555899068adb7f to your computer and use it in GitHub Desktop.
test gist code snippet
<?php
private function readfile_chunked($root, $filename){
$handle = fopen($root.$filename, 'rb');
if($handle === false){
return false;
}
// How many bytes per chunk.
// At each time, the server will read and send the data to client site chunk by chunk.
// It helps us to save memory usage.
$chunksize = 1*(1024*1024);
while (!feof($handle)) {
$buffer = fread($handle, $chunksize);
print $buffer;
}
return fclose($handle);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment