I have downloadable products for sale.

I have created custom meta boxes to hold the file data I need, it allows me to upload fine to the custom meta the .doc and the .pdf files...

However when I try and upload a .mobi and a .epub - it doesn't upload the files...

I suspect I will also hit issues when I try and follow the download link to download the files also - but I will cross that bridge when I come to it.

Any help on this would be fantastic.

1 Answer 1


Assuming that you are using the WordPress native Media uploader then you can use the upload_mimes filter hook to add or remove allowed file types, for example:

function custom_myme_types($mime_types){

    //Adding avi extension
    $mime_types['avi'] = 'video/avi'; 

    //Removing the pdf extension

    return $mime_types;

add_filter('upload_mimes', 'custom_myme_types', 1, 1);

You can see that to add a file type you just add to the array with the file extension as the key and the mime type as the value do the MIME type for .mobi format file is application/x-mobipocket-ebook and for .epub format is application/epub+zip

  • 5
    Also I'd like to add to Bainternet's answer is that if you are using Apache for example it might not know about the file extensions .mobi/.epub and their corresponding mime types. If you get a file not found when trying to view the file you may need to add the mime types to the server. For Apache you can do this using your htaccess file and add something like this: AddType application/x-shockwave-flash swf
    – Scott
    Feb 17, 2012 at 12:07
  • Thanks, I've tried adding the above code to my theme functions.php and it starts saying headers are already sent. I am using Apache and I've already amended my .htaccess file. Feb 17, 2012 at 12:17
  • I tell a lie, I appear to have got it working. Excellent. Feb 17, 2012 at 12:33
  • Glad you got it working
    – Bainternet
    Feb 17, 2012 at 14:42

Not the answer you're looking for? Browse other questions tagged or ask your own question.