Код: Выделить всё
function downloadAttachmentKb($filesDownload)
{
if (empty($filesDownload)){
return false;
}
set_time_limit(0);
$DownloadDir = "./files/kbfiles/".$filesDownload ;
$DownloadFiles = basename( $filesDownload);
$DovnloadSize = filesize( $DownloadDir);
if (!file_exists($DownloadDir) && !is_writable($DownloadDir)){
die("errore");
}
$MimeFile = mime_content_type($DownloadDir);
if ($MimeFile === false){
header("Content-Type: application/force-download");
}else{
header(header: "Content-Type:".$MimeFile."");
}
if (strpos($_SERVER['HTTP_USER_AGENT'], "MSIE")){
header("Content-Disposition: inline ; filename=\"". $DownloadFiles."\"");
} else{
header(header: "Content-Disposition: attachment; filename=\"". $DownloadFiles ."\"");
}
header(header: "Content-Length: ". filesize($DownloadDir));
header("Content-Description: File Transfer");
header("Content-Transfer-Encoding: binary");
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: public");
ob_clean();
flush();
echo file_get_contents($DownloadDir);
}
?>
Подробнее здесь: https://stackoverflow.com/questions/797 ... mpty-files