What MIME-type to use as general purpose?

前端 未结 1 1215
南旧
南旧 2021-01-04 12:32

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

相关标签:
1条回答
  • 2021-01-04 13:01

    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.

    0 讨论(0)
提交回复
热议问题