<?php
if (isset($_GET['filename'])) {
$filepath = 'upload/' . $_GET['filename'];
if (file_exists($filepath)) {
header('Content-Description: File Transfer');
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment; filename="' . $_GET['filename'] . '"');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($filepath));
ob_clean();
flush();
readfile($filepath);
exit;
} else {
echo "文件不存在。";
}
}
?>