What MIME-type to use as general purpose?

风流意气都作罢 提交于 2019-11-30 02:40:36

问题


I have a PHP script that I use to download different types of files (PDF, JPEG, RAR end other). Works great, however I noticed an issue there with the MIME-type.

Is there a universal MIME-type I can safely use for "general purpose"? I am thinking of application/octet-stream for all file types.

Or should I do the MIME for each file type individually?

It's supposed to deliver downloads, it's not important to open the files in apps directly.


回答1:


If you just want to deliver files and don't care about the type of application needed to open it, then it's safe to specify the file mime type as application/octet-stream. However you should specify that it should be saved and should not be attempted to be opened inline within the browser.

you should specify the header as: Content-Type: application/octet-stream Content-Disposition: attachment; filename="file.png"

It informs the browser (or the client application) that the file should be downloaded and should not be attempted to be opened inline.



来源:https://stackoverflow.com/questions/20163864/what-mime-type-to-use-as-general-purpose

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!