在通过HTTP下载文件时是否应使用content-transfer-encoding标头? [英] Should content-transfer-encoding headers be use when downloading files via HTTP?
问题描述
我最近遇到了如何使用PHP强制下载文件其中描述了设置 Content-Transfer-Encoding
。当用于通过HTTP下载文件时,此标头在与此应用程序一起使用时是否适用(它似乎与电子邮件相关)?如果是这样,应该为MS Word和Excel文件,ZIP文件,PDF和文本设置什么?
I recently came across How to force file download with PHP which describes setting Content-Transfer-Encoding
. Is this header applicable when used with this application when used to download a file via HTTP (it appears to be email related)? If so, what should it be set as for MS Word and Excel files, ZIP files, PDFs, and Text?
header("Content-Transfer-Encoding: Binary");
推荐答案
它被虔诚地包含在carg-cult copy-粘贴程序员,因为它是在PHP.net上的 readfile()
联机帮助页的评论中提到。
It has been religiously included by carg-cult copy-paste programmers since it was mentioned in a comment to the readfile()
manpage on PHP.net.
It indeed has little to do with HTTP and you can safely remove it.
这篇关于在通过HTTP下载文件时是否应使用content-transfer-encoding标头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!