how to upload and allow downloads of .mobi and .epub formats

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…

Read More

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.

Related posts

Leave a Reply

1 comment

  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
        unset($mime_types['pdf']); 
    
        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