Adding mime types to allow epub file upload

I want to add file types in my child theme’s functions.php file so I can upload an epub file.

Is this correct:

function allow_personal_uploads ( $existing_mimes=array() ) {

// allow uploading .MOBI and .EPUB files

$existing_mimes['mobi'] = 'application/x-mobipocket-ebook'; 

$existing_mimes['epub'] = 'application/epub+zip'; 



// return amended array

return $existing_mimes;

}

add_filter(‘upload_mimes’, ‘allow_personal_uploads’);

Hi @ziggybri,

Thanks for writing in, yup that looks good. If not, please see the following links:

Hope it helps,
Cheers!

It didn’t work. Any thoughts?

Hi @ziggybri,

Try adding define('ALLOW_UNFILTERED_UPLOADS', true); on your wp-config.php file

Add it before the line that says /* That's all, stop editing! Happy blogging. */
then test it if that allows you to upload epub file.

If the issue persists, please contact your hosting support, this might be a server-level restriction and not in Wordpress.

Thanks,

Just wanted to update here for anyone else looking for this answer. The plugin WP Add Mime Types worked for me.

Glad you’ve sorted out your MIME types problem.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.