Файл: upload/core/download-mes.php
Строк: 29
<?php
$allowedDir = $_SERVER['DOCUMENT_ROOT'] . '/uploads/chats/';
$filename = basename($_GET['file']);
$filepath = $allowedDir . $filename;
if (!file_exists($filepath)) {
http_response_code(404);
exit('Файл не найден');
}
$ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
$imageExt = ['jpg','jpeg','png','gif','webp'];
if (in_array($ext, $imageExt)) {
header('Content-Type: ' . mime_content_type($filepath));
readfile($filepath);
exit;
}
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . $filename . '"');
header('Content-Length: ' . filesize($filepath));
readfile($filepath);
exit;
?>