Recently I build a PHP script for dynamically downloading files, and I came across the need to provide the right Mime-Type for each file I set to download. I wrote a function in PHP that gets file extension (with or without the dot prefix) and returns the correct Mime-Type.

This function also returns the general purpose mime-type for missing or unknown file types.

General purpose MIME-TYPE

Use:  application/octet-stream




1 Comment

Leave a comment