Readfile over internet connection
Login or Register to Bookmark this snippet
Reads the content of a file, either local or remote (http://blah) in chunks that are protocol safe and avoid network disruption.
<?php
function readfile_chunked ($filename) {
$chunksize = 1*(1024*1024); // how many bytes per chunk
$buffer = '';
$contents = '';
$handle =
fopen($filename,
'rb');
if ($handle === false) {
return false;
}
$buffer =
fread($handle,
$chunksize);
$contents .= $buffer;
}
return $contents;
}
?>
Added by JC on 12th November, 2007
There are no comments about this snippet.
You must be registered and logged in to post a comment.
Login here to post a comment