<?php
if (isset($_GET['file'])) {
    $file = basename($_GET['file']); // Prevent directory traversal
    $file_path = __DIR__ . '/assets/images/pdf/' . $file; // Adjust file path

    if (file_exists($file_path)) {
        // Clear output buffer
        ob_clean();
        flush();

        // Set headers
        header('Content-Type: application/pdf');
        header('Content-Disposition: attachment; filename="' . $file . '"');
        header('Content-Length: ' . filesize($file_path));

        // Output file
        readfile($file_path);
       
        exit();
    } else {
        http_response_code(404);
        echo "File not found.";
        exit();
    }
     echo "<script>
window.location = 'https://crowncrestrealty.com/thank-you';</script>";
} else {
    http_response_code(400);
    echo "No file specified.";
    exit();
}
?>

