21 lines
567 B
PHP
21 lines
567 B
PHP
<?php
|
||
|
||
if (file_exists($filePath)) {
|
||
if (ob_get_level()) {
|
||
ob_end_clean();
|
||
}
|
||
|
||
if (!isset($fileName)) {
|
||
$fileName = basename($filePath);
|
||
}
|
||
|
||
header('Connection: close');
|
||
header('Content-Type: application/octet-stream');
|
||
header('Content-Disposition: attachment; filename=' . $fileName);
|
||
header('Content-Transfer-Encoding: binary');
|
||
header('Cache-Control: must-revalidate');
|
||
// header('Transfer-Encoding: chunked');
|
||
// Читаем файл и отправляем его пользователю
|
||
readfile($filePath);
|
||
}
|