Php content-types

I play with exporting dynamic data from a database to a browser. I see that there are different types of content, and some of them I need to ask. I have to ask the wrong questions since I do not find detailed information in search engines.

Here are a few of the ones I've seen from personal scenarios of people.

header("Content-type: application/zip;");
header("Content-type: application/csv");
header("Content-type: application/x-msdownload");
header('Content-Type: application/vnd.ms-excel');
header('Content-type: application/octet-stream');

I can clearly understand "zip", "csv". But others leave me questions. For example, when do I use them?

I tried x-msdownload for xls files and it seems to work. But I see others using vnd.ms-excel. What for? Should I use this? I also see the octet stream used to load the csv file created by php. Why?

In any case, I do not find much on php.net. Not to say that this is not, but clear descriptions are not shown.

Does anyone know a site that breaks down different types of content and why are they used?

+3
source share
2 answers

MIME types are not defined by PHP, but they are defined by the IETF in RFC2046 . Most of them are intended for single file types only and are only useful if you want to make such files. Types starting with vndare vendor specific MIME types. Types starting with x-are not defined. They mean something like "my user type", but you should not rely on it. text/plainusually used for no more specific ascii content, but application/octet-streamalmost the same for binary content.

+1
source

http://www.iana.org/assignments/media-types/ contains an exhaustive list of mime types and their associated definitions.

+4
source

Source: https://habr.com/ru/post/1788017/


All Articles