Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

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 ex:

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);

Yoy 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

share|improve this answer
4  
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 –  Brady Feb 17 '12 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. –  Michael Stott Feb 17 '12 at 12:17
    
I tell a lie, I appear to have got it working. Excellent. –  Michael Stott Feb 17 '12 at 12:33
    
Glad you got it working –  Bainternet Feb 17 '12 at 14:42
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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