0 ? get_document($documentId) : null; if (!$document) { http_response_code(404); echo 'Dokumen tidak ditemukan.'; exit; } if (!can_access_document_file($document)) { http_response_code(403); echo 'Dokumen belum tersedia untuk diakses.'; exit; } $filePath = __DIR__ . '/' . ltrim((string)$document['attachment_path'], '/'); if (!is_file($filePath)) { http_response_code(404); echo 'Lampiran tidak ditemukan di server.'; exit; } header('Content-Type: ' . attachment_mime((string)$document['attachment_ext'])); header('Content-Length: ' . filesize($filePath)); header('Content-Disposition: ' . $disposition . '; filename="' . rawurlencode((string)$document['attachment_name']) . '"'); header('X-Content-Type-Options: nosniff'); readfile($filePath); exit;