Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个下载ppt文件的页面。我想添加一项功能,无需提供登录凭据,该页面将不会被下载。我的代码是这样的:
if(!isset($_SESSION['user']) && basename($_SERVER['PHP_SELF']) == 'XYZ.ppt'){ header('location:index.php'); }
但是在浏览器中,如果我键入该 ppt 文件的完整路径,则它不会检查会话并自动下载。
提前致谢。
在php中,你可以下载喜欢
<?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'); ?>