Adding Custom Mime Types for WordPress Uploads

Wordpress allows the upload of different filetypes to posts through custom fields, but it only understands certain file types by default. As an example, if you wanted to allow the upload of ebook formats like epub and mobi, you need to tell Wordpress how to understand those filetypes. If Wordpress doesn't understand what the files are, when you upload them you might not see that the file has uploaded when viewing the post edit screen. If you have allowed that file type to be uploaded in your form, the file has probably uploaded fine and the record in the database should be correct, it would just look like nothing has been uploaded in your post. The following snippet can go into your theme's functions file or, if you are using a plugin to add any custom hooks to your site, it could go in there.

It uses the upload_mimes filter action to get the array of existing mime types and then adds our custom ones on the end. Modify it to add the filetypes you want to upload and their corresponding mime type.