Last active
October 1, 2015 12:26
-
-
Save nqphuong/ad551d555899068adb7f to your computer and use it in GitHub Desktop.
test gist code snippet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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