【问题标题】:allow user to download .html and .css file without forcing them to right click, save as允许用户下载 .html 和 .css 文件而不强制他们右键单击,另存为
【发布时间】:2012-06-26 13:19:17
【问题描述】:

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

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

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

【问题讨论】:

    标签: php html css


    【解决方案1】:

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

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-13
      • 2014-05-21
      • 1970-01-01
      • 2012-10-08
      相关资源
      最近更新 更多