Html content type zip

Common MIME types

This topic lists the most common MIME types with corresponding document types, ordered by their common extensions.

The following two important MIME types are the default types:

  • text/plain is the default value for textual files. A textual file should be human-readable and must not contain binary data.
  • application/octet-stream is the default value for all other cases. An unknown file type should use this type. Browsers are particularly careful when manipulating these files to protect users from software vulnerabilities and possible dangerous behavior.

IANA is the official registry of MIME media types and maintains a list of all the official MIME types. This table lists important MIME types for the Web:

Extension Kind of document MIME Type
.aac AAC audio audio/aac
.abw AbiWord document application/x-abiword
.arc Archive document (multiple files embedded) application/x-freearc
.avif AVIF image image/avif
.avi AVI: Audio Video Interleave video/x-msvideo
.azw Amazon Kindle eBook format application/vnd.amazon.ebook
.bin Any kind of binary data application/octet-stream
.bmp Windows OS/2 Bitmap Graphics image/bmp
.bz BZip archive application/x-bzip
.bz2 BZip2 archive application/x-bzip2
.cda CD audio application/x-cdf
.csh C-Shell script application/x-csh
.css Cascading Style Sheets (CSS) text/css
.csv Comma-separated values (CSV) text/csv
.doc Microsoft Word application/msword
.docx Microsoft Word (OpenXML) application/vnd.openxmlformats-officedocument.wordprocessingml.document
.eot MS Embedded OpenType fonts application/vnd.ms-fontobject
.epub Electronic publication (EPUB) application/epub+zip
.gz GZip Compressed Archive application/gzip
.gif Graphics Interchange Format (GIF) image/gif
.htm , .html HyperText Markup Language (HTML) text/html
.ico Icon format image/vnd.microsoft.icon
.ics iCalendar format text/calendar
.jar Java Archive (JAR) application/java-archive
.jpeg , .jpg JPEG images image/jpeg
.js JavaScript text/javascript (Specifications: HTML and RFC 9239)
.json JSON format application/json
.jsonld JSON-LD format application/ld+json
.mid , .midi Musical Instrument Digital Interface (MIDI) audio/midi , audio/x-midi
.mjs JavaScript module text/javascript
.mp3 MP3 audio audio/mpeg
.mp4 MP4 video video/mp4
.mpeg MPEG Video video/mpeg
.mpkg Apple Installer Package application/vnd.apple.installer+xml
.odp OpenDocument presentation document application/vnd.oasis.opendocument.presentation
.ods OpenDocument spreadsheet document application/vnd.oasis.opendocument.spreadsheet
.odt OpenDocument text document application/vnd.oasis.opendocument.text
.oga OGG audio audio/ogg
.ogv OGG video video/ogg
.ogx OGG application/ogg
.opus Opus audio audio/opus
.otf OpenType font font/otf
.png Portable Network Graphics image/png
.pdf Adobe Portable Document Format (PDF) application/pdf
.php Hypertext Preprocessor (Personal Home Page) application/x-httpd-php
.ppt Microsoft PowerPoint application/vnd.ms-powerpoint
.pptx Microsoft PowerPoint (OpenXML) application/vnd.openxmlformats-officedocument.presentationml.presentation
.rar RAR archive application/vnd.rar
.rtf Rich Text Format (RTF) application/rtf
.sh Bourne shell script application/x-sh
.svg Scalable Vector Graphics (SVG) image/svg+xml
.tar Tape Archive (TAR) application/x-tar
.tif , .tiff Tagged Image File Format (TIFF) image/tiff
.ts MPEG transport stream video/mp2t
.ttf TrueType Font font/ttf
.txt Text, (generally ASCII or ISO 8859-n) text/plain
.vsd Microsoft Visio application/vnd.visio
.wav Waveform Audio Format audio/wav
.weba WEBM audio audio/webm
.webm WEBM video video/webm
.webp WEBP image image/webp
.woff Web Open Font Format (WOFF) font/woff
.woff2 Web Open Font Format (WOFF) font/woff2
.xhtml XHTML application/xhtml+xml
.xls Microsoft Excel application/vnd.ms-excel
.xlsx Microsoft Excel (OpenXML) application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
.xml XML application/xml is recommended as of RFC 7303 (section 4.1), but text/xml is still used sometimes. You can assign a specific MIME type to a file with .xml extension depending on how its contents are meant to be interpreted. For instance, an Atom feed is application/atom+xml , but application/xml serves as a valid default.
.xul XUL application/vnd.mozilla.xul+xml
.zip ZIP archive application/zip
.3gp 3GPP audio/video container video/3gpp ; audio/3gpp if it doesn’t contain video
.3g2 3GPP2 audio/video container video/3gpp2 ; audio/3gpp2 if it doesn’t contain video
.7z 7-zip archive application/x-7z-compressed
Читайте также:  Php echo all form post

Found a content problem with this page?

This page was last modified on Apr 10, 2023 by MDN contributors.

Источник

What are All the Possible Values for HTTP “Content-Type” Header

The HTTP “Content-Type” Header is the identifier used to make the HTTP client and server understand the content or media type of the resource added in the document. It instructs the server on which media type the browser is looking for. The HTTP Content-Type header is supported by many browsers including “Google Chrome”, “Mozilla Firefox”, “Internet Explorer”, “Safari”, “Samsung browser” and “Opera”.

This blog will discuss about different values of the HTTP “Content-Type” Header.

How to Use the HTTP “Content-Type” Header?

The syntax to use the HTTP “Content-Type” Header is as follows:

Types of the Values in HTTP “Content-Type” Header

The types of the content type values used in the HTTP “Content-Type” Header are as follows:

All Values in HTTP “Content-Type” Header

There are multiple values for each content type used in the HTTP “Content-Type” Header. Let’s enlist all the possible values of each content type of the HTTP “Content-Type” Header.

Application

When an application is supposed to be added to the document, the “application” content type is used in the header. There are different types of application file formats that the HTTP supports:

    • application/java-archive
    • application/EDI-X12
    • application/javascript
    • application/xml
    • application/pdf
    • application/octet-stream
    • application/ogg
    • application/zip
    • application/xhtml+xml
    • application/x-shockwave-flash
    • application/json
    • application/x-www-form-urlencoded
    • application/ld+json
    • application/EDIFACT

    When there is a need to add the audio files to the document, the “audio” content type is used in the header. Audio can be added in different formats as follows:

    To add images in the document of different formats, there is the “image” content type and the following are the possible values for the Image content type:

      • image/gif
      • image/tiff
      • image/vnd.djvu
      • image/jpeg
      • image/svg+xml
      • image/png
      • image/x-icon
      • image/vnd.microsoft.icon

      The “multipart” content type is added to upload files or content of different types in a single document. The following four values for the “multipart” content-type are valid in HTTP:

        • multipart/mixed
        • multipart/related
        • multipart/form-data
        • multipart/alternative

        When there is a text file supposed to be added to the document, the “text” content type is used with any of the following six text format values:

          • text/css
          • text/javascript (obsolete)
          • text/plain
          • text/html
          • text/xml
          • text/csv

          To efficiently display the videos, the “video” content type is used with the following content type values:

            • video/mpeg
            • video/x-ms-wmv
            • video/x-msvideo
            • video/webm
            • video/mp4
            • video/x-flv
            • video/quicktime

            VND (Vendor-specific)

            Following are the values for the VND (Vendor-specific) content type for HTTP:

              • application/vnd.android.package-archive
              • application/vnd.openxmlformats-officedocument.presentationml.presentation
              • application/vnd.mozilla.xul+xml
              • application/vnd.oasis.opendocument.text
              • application/vnd.oasis.opendocument.presentation
              • application/vnd.oasis.opendocument.spreadsheet
              • application/vnd.ms-powerpoint
              • application/vnd.oasis.opendocument.graphics
              • application/vnd.ms-excel
              • application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
              • application/vnd.openxmlformats-officedocument.wordprocessingml.document
              • application/msword

              These are all the possible values for the HTTP “Content-Type” Header.

              Conclusion

              The HTTP “Content-Type” Header instructs the HTTP clients and server which type of file they must execute. There are multiple types of the HTTP “Content-Type” Header that includes application, audio, image, multipart, text, and video. Moreover, it comprises multiple values for these content or media types, for instance, text/html, application/pdf, audio/mpeg, etc. This blog is a good guide about different values used in the HTTP “Content-Type” header.

              About the author

              Hadia Atiq

              A Software Engineer and Technical Writer passionate about learning and spreading knowledge of the latest technology. I utilize my writing skills to help readers understand the importance and usage of modern technology.

              Источник

              Работа с MIME-типами в PHP

              «Internet Media Types» или «Медиа типы» — является стандартом RFC 6838, который описывает формат файла. Причем браузеры используют MIME-типы в качестве основного критерия, не воспринимая расширения файлов.

              MIME-тип состоит из типа и подтипа — двух значений разделённых « / », без использования пробелов и в нижнем регистре, например HTML страница:

              Полный список MIME типов можно посмотреть тут.

              К медиа типу может быть добавлен параметр для указания дополнительных деталей (например кодировка):

              Как узнать MIME-тип загруженного файла

              При загрузке файла через форму, MIME-тип файла доступен в массиве $_FILES , например:

              Для определения MIME уже загруженного файла существует PHP-функция mime_content_type().

              echo mime_content_type(__DIR__ . '/image.png'); // image/png echo mime_content_type(__DIR__ . '/text.txt'); // text/plain

              При работе с изображениями, MIME-тип можно получить с помощью функции getimagesize():

              $filename = __DIR__ . '/image.png'; $info = getimagesize($filename); print_r($info);

              Результат:

              Array ( [0] => 221 [1] => 96 [2] => 3 [3] => width="221" height="96" [bits] => 8 [mime] => image/png )

              Важно помнить что при проверке файлов нельзя полагаться только на проверку MIME, т.к. его значение может быть скомпрометировано. Поэтому нужно проводить более детальную проверку (например по размеру изображения или его пересохранить в предполагаемом формате).

              Отправка файлов из PHP

              В PHP-скриптах, перед отправкой файлов клиенту, необходимо отправлять заголовок Content-Type , например файл XML:

              $content = '. '; header("Content-Type: text/xml; charset=utf-8"); echo $content; exit();
              $file = ROOT_DIR . '/market.zip'; header('Content-type: application/zip'); header('Content-Transfer-Encoding: Binary'); header('Content-length: ' . filesize($file)); header('Content-disposition: attachment; filename="' . basename($file) . '"'); readfile($file); exit();

              Вывод изображения в зависимости от расширения файла:

              $filename = __DIR__ . '/image.png'; $ext = mb_strtolower(mb_substr(mb_strrchr($filename, '.'), 1)); switch ($ext) < case 'png': header('Content-type: image/png'); break; case 'jpg': case 'jpeg': header('Content-type: image/jpeg'); break; case 'gif': header('Content-type: image/gif'); break; case 'wepb': header('Content-type: image/webp'); break; >readfile($filename); exit();

              Источник

Оцените статью