我想在我的网站(html / php)中创建一个下载HTML文件的链接,而不在导航器中显示此文件。有可能吗?
答案 0 :(得分:2)
编写一个小PHP脚本,强制浏览器下载文件:
$fullPath = 'the/Path/To/The/File.html';
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Length: ' . filesize($fullPath));
header('Content-Disposition: attachment; filename="' . basename($fullPath) . '"');
readfile($fullPath);
exit();