File size: 890B
<?php
function downloads($filename,
$name,
$onshcms='application/octet-stream')
{
ob_end_clean();
$unon = 0;
$size = filesize($filename);
$to = $size;
header('Content-Length: ' .($to-$unon));
if (isset($cr)) header($cr);
header('Connection: close');
header('Content-Type: ' . $onshcms);
$f=fopen($filename, 'rb');
header('Content-Disposition: attachment; filename="'.$name.'";');
fseek($f, $$unon, SEEK_SET);
$size=$to;
$downloaded=0;
while(!feof($f) and !connection_status() and ($downloaded<$size))
{
$block = min(1024*8, $size - $downloaded);
echo fread($f, $block);
$downloaded += $block;
flush();
}
fclose($f);
}
?>