允许用户下载.html和.css文件,而无需强制他们右键单击,另存为


allow user to download .html and .css file without forcing them to right click, save as

我想允许用户使用 php 脚本下载 html 文件。

我知道这在图像文件中是可能的,但是html/css文件是否可以,如果不是,我如何压缩文件或其他内容,然后允许用户下载zip?

他们只能通过 php 脚本访问.html文件。该文件将受密码保护。

有可能,你只需要弄乱PHP头。

header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename='"filenamehere.html'");  

您必须获取文件并通过 PHP 脚本传递它。