<?php
$file = basename($_GET['file'] ?? '');

if ($file == '') {
    die("Data tidak ditemukan");
}

$paths = [
    $_SERVER['DOCUMENT_ROOT'] . "/ebos/upload/rekomendasi/" . $file,
    $_SERVER['DOCUMENT_ROOT'] . "/upload/rekomendasi/" . $file,
];

$path = null;
foreach ($paths as $p) {
    if (file_exists($p)) {
        $path = $p;
        break;
    }
}

if (!$path) {
    die("Data tidak ditemukan");
}

header("Content-Type: application/pdf");
header("Content-Disposition: inline; filename=\"$file\"");
header("Content-Length: " . filesize($path));
readfile($path);
exit;
