Mime Types

Mime Types used to deliver content on the Internet.

  1. How to use the AVIF image format in PHP; A1 or AVIF is a new image format that offers better compression than WebP, JPEG and PNG, and that already works in Google Chrome.
  2. About the correct mime type for MP4 files, delivering video files from PHP, working with video codecs and containers, editing, and more.
  3. Information about the WebP content type, and how we might handle webp images in PHP.
  4. About using the PNG mime type to deliver images to clients from the server side.
  5. The HTML Mime Type is the default used by PHP, and you need to actively change it to deliver other types of content.
  6. There has been some confusion about which mime type is correct for plain text on the web, and while both might work, only one is correct.
  7. Tutorial on delivering jpeg files with the correct mime type and headers using PHP.

Mime Types

Articles on correct Mime Types for different file extensions or content types.

These Mime Types may be used from within PHP and other programming languages when delivering content through the HTTP protocol.

Instead of trying to handle serving of static files yourself, you can use Beamtic's File Handler Library

Using a file extension to determine the Mime Type is not always reliable or safe, but it is the recommended way to determine the content of a file that you have control over. The reason for this is, file extensions are actually very user friendly. Only for user-contributed files should you take extra steps to verify that a file is what a user claims it is.

Saving files without extensions, while it is possible, is not recommended.

It is also possible to store files in a database, but this is usually not recommended. Instead, you could store the absolute path to the file in the local file system.