<?php
// 假设 $pdf_data 包含了 PDF 文件的二进制数据
$pdf_data = file_get_contents('E:/phpstudy_pro/WWW/images/1.pdf');
// 设置响应头
header('Content-Disposition: attachment; filename="example.pdf"');//重命名为example.pdf
header('Content-Length: ' . strlen($pdf_data));
header('Content-Type: application/pdf');
// 清除任何现有的输出缓冲区
ob_clean();
flush();
// 将 PDF 数据发送给浏览器
echo $pdf_data;
// 终止脚本以防止任何额外的输出
exit;
?>
05-23
05-11
1957
