{{tag>wordpress mime}}
====== Upload additional file types in WordPress ======
This fixes the error "Sorry, This File Type Is Not Permitted for Security Reasons".
In ''wp-config.php'' add this:
define('ALLOW_UNFILTERED_UPLOADS', true);
If you are not using some custome theme but a Wordpress builder of some kind, edit the ''wp-includes/functions.php''. Otherwise go to your theme folder functions.php file (''wp-content/themes/yourtheme/functions.php''. Add this to enable ''svg'' upload:
// Allow additional MIME type upload
function my_custom_mime_types( $mimes ) {
// New allowed mime types.
$mimes['svg'] = 'image/svg+xml';
$mimes['svgz'] = 'image/svg+xml';
// Optional. Remove a mime type.
unset( $mimes['exe'] );
return $mimes;
}
add_filter( 'upload_mimes', 'my_custom_mime_types' );
These changes will most likely be overwritten on next theme or WP update.
====== Tested on ======
* WP 5.7
* PHP 7.3.27-1~deb10u1
====== See also ======
====== References ======
* https://www.elegantthemes.com/blog/wordpress/how-to-fix-the-sorry-this-file-type-is-not-permitted-for-security-reasons-error-in-wordpress
* https://neliosoftware.com/blog/how-to-upload-additional-file-types-in-wordpress/