[英]php force download headers
哪些标头最重要的是强制下载以及哪些标头由浏览器自动填充
例如
header('Content-Description: File Transfer');
header('Content-type: application/zip');
header('Content-Length: '.sprintf("%u", filesize($zip_out)));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Disposition: attachment; filename="'.basename($zip_out).'"');
我省略除了第1行和第2行之外的所有标题,下载工作正常为什么/如何?
Content-Disposition: attachment
表示您的浏览器内容是附件。 因此浏览器将开始将内容下载为文件。
根据RFC 6266 :
如果处置类型与“附件”匹配(不区分大小写),则表示收件人应提示用户在本地保存响应,而不是正常处理(根据其媒体类型)。
Content-type: application/zip
表示您的浏览器内容被压缩,并且通常使浏览器将内容下载为文件,即使省略了Content-Disposition: attachment
,因为这是zipped浏览器的默认行为内容。
我从未在任何与HTTP相关的规范中看到Content-Description
标头,我认为它根本不会影响下载。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.