function dnlf($dnlf){
die('Заголовки отправлены');
}
if (ini_get('zlib.output_compression')) {
ini_set('zlib.output_compression', 'Off');
}
$fd = @fopen($dnlf, 'rb');
"sis" => "application/vnd.symbian.install",
"amr" => "audio/amr",
"jad" => "text/vnd.sun.j2me.app-descriptor;charset=UTF-8",
"jar" => "application/java-archive",
"mp4" => "video/mp4",
"3gp" => "video/3gpp",
"rar" => "application/x-rar-compressed",
"doc" => "application/msword",
"exe" => "application/octet-stream",
"pdf" => "application/pdf",
"zip" => "application/zip",
"mp3" => "audio/mpeg",
"wav" => "audio/x-wav",
"bmp" => "image/bmp",
"gif" => "image/gif",
"jpg" => "image/jpeg",
"png" => "image/png",
"css" => "text/css",
"txt" => "text/plain",
"mpg" => "video/mpeg",
"avi" => "video/x-msvideo",
);
$type = $arr_types[$ext];
} else {
$type = 'application/force-download';
}
if (isset($_SERVER['HTTP_RANGE'])) {
$range = $_SERVER['HTTP_RANGE'];
}
} else {
$range = 0;
}
if ($range) {
header($_SERVER['SERVER_PROTOCOL'] . ' 206 Partial Content');
} else {
header($_SERVER['SERVER_PROTOCOL'] . ' 200 OK');
}
header('Last-Modified: ' . $ftime);
header('Accept-Ranges: bytes');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Cache-Control: private', false);
header('Content-Type: ' . $type . '');
header('Content-Description: inline; File Transfer');
header('Content-Disposition: attachment; filename="' . basename($dnlf) . '";', false);
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . ($fsize - $range));
if ($range) {
header('Content-Range: bytes ' . $range . '-' . ($fsize - 1) . '/' . $fsize);
}
$speed = 1024*8; // 8 - speed/kb
while(!feof($fd) && connection_status()==0) { // проверяем коннект, чтоб процесс не висел при дисконнекте
$buf = fread($fd, $speed); // отдаем файл порцайками , менее напрягает сервер, актуально для файлов более 1 гб
print($buf);
#sleep(1); // if speed > 8 разкоментирование приведет к ограничению скорости
}
} else {
}
}