<?php
// serve_download.php
// 必要：$pathInfo

if (!$pathInfo['exists'] || !$pathInfo['is_file']) {
    http_response_code(404);
    echo "404 Not Found";
    exit;
}
$mime = @mime_content_type($pathInfo['full']) ?: 'application/octet-stream';
header("Content-Type: {$mime}");
header('Content-Disposition: attachment; filename="'.basename($pathInfo['full']).'"');
$size = @filesize($pathInfo['full']);
if ($size !== false) header("Content-Length: {$size}");
readfile($pathInfo['full']);
