gpt4 book ai didi

php - 如何使用php渲染pdf文件

转载 作者:行者123 更新时间:2023-12-03 09:25:50 25 4
gpt4 key购买 nike

我们有一些 PDF 文件,我们希望它通过 php 呈现,而不是直接提供文件链接,以便只有经过身份验证的用户才能下载 pdf 文件。因此我们不需要向用户提供文件路径。

可能吗?

曼格什

最佳答案

可以,这是一个示例:

<?php
$file = './path/to/the.pdf';
$filename = 'You dont know where I am.pdf';

header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="' . $filename . '"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . filesize($file));
header('Accept-Ranges: bytes');

@readfile($file);
?>

关于php - 如何使用php渲染pdf文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21566450/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com