Files
bolsa/php/download_csv.php
2026-07-02 14:15:39 +00:00

28 lines
627 B
PHP

<?php
declare(strict_types=1);
require_once __DIR__ . '/session.php';
if (empty($_SESSION['user_id'])) {
header('Location: ../index.php');
exit;
}
$csvFilePath = __DIR__ . '/../assets/csv/actions.csv';
if (!is_readable($csvFilePath)) {
http_response_code(404);
echo 'Fichier CSV introuvable.';
exit;
}
header('Content-Type: text/csv; charset=UTF-8');
header('Content-Disposition: attachment; filename="actions.csv"');
header('Content-Length: ' . (string) filesize($csvFilePath));
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Pragma: no-cache');
readfile($csvFilePath);
exit;