<?php
// telecharger_latex.php
$file = $_GET['file'] ?? '';

$tmpDir = sys_get_temp_dir();
$filePath = $tmpDir . '/' . basename($file);

if (!file_exists($filePath)) {
    http_response_code(404);
    die('Fichier introuvable');
}

header('Content-Type: application/zip');
header('Content-Disposition: attachment; filename="yamwi_export_latex.zip"');
header('Content-Length: ' . filesize($filePath));
readfile($filePath);

// Supprimer le fichier après téléchargement
unlink($filePath);

exit;
?>
