我想提供下载发票.目前我使用的是简单的编号方案(invoice-01.pdf,invoice-02.pdf等).我知道我可以使用哈希来掩盖数据.
在
php.net甚至有一个例子
原文链接:/php/139481.html<?PHP // We'll be outputting a PDF header('Content-type: application/pdf'); // It will be called downloaded.pdf header('Content-Disposition: attachment; filename="downloaded.pdf"'); // The PDF source is in original.pdf readfile('original.pdf'); ?>
或者扩展一下
<?PHP if ( can_this_file_be_downloaded() ) { header('Content-type: application/pdf'); header('Content-Disposition: attachment; filename="invoice.pdf"'); readfile("{$_GET['filename']}.pdf"); } else { die("None shall pass"); } ?>