Code to Allow Uploading of Known File Types in WordPress

/* Allow Uploading of Known File Types */
function wpflt_allow_custom_file_types( $mimes ) {
$mimes['svg'] = 'image/svg+xml';
$mimes['woff2'] = 'application/x-font-woff2';
$mimes['doc'] = 'application/msword';
return $mimes;
}
add_filter( 'upload_mimes', 'wpflt_allow_custom_file_types' );

By Default WordPress supports Uploading the following file types:

Images: .jpg, .jpeg, .png, .gif, .ico, .webp

Documents: .pdf, .doc, .docx, .ppt, .pptx, .pps, .ppsx , .odt , .xls, .xlsx, .psd

Audio: .mp3, .m4a, .ogg, .wav

Video: .mp4, .m4v (MPEG-4), .mov , .wmv, .avi, .mpg, .ogv, .3gp, .3g2

But there are other known file types in WordPress which are not allowed to be uploaded for security reasons.

Sorry, This File Type Is Not Permitted for Security Reasons” is the type of error message you will get when you try uploading files with extensions which are not allowed in WordPress.

To allow a specific file type, add the above code to your child theme’s functions.php. Specify the file extension along with the MIME type in the list. In the above code, we have added support for WOFF2, SVG and DOC. Modify according to your needs.

Utilize the below List of WordPress supported File Types to add more file support.

Extension MIME Type
.bmp image/bmp
.tif image/tiff
.tiff image/tiff
.asf video/x-ms-asf
.asx video/x-ms-asf
.wm video/x-ms-wm
.wmx video/x-ms-wmx
.divx video/divx
.flv video/x-flv
.qt video/quicktime
.mpe video/mpeg
.webm video/webm
.mkv video/x-matroska
.txt text/plain
.asc text/plain
.c text/plain
.cc text/plain
.h text/plain
.csv text/csv
.tsv text/tab-separated-values
.ics text/calendar
.rtx text/richtext
.css text/css
.htm text/html
.html text/html
.m4b audio/mpeg
.ra audio/x-realaudio
.ram audio/x-realaudio
.mid audio/midi
.midi audio/midi
.wax audio/x-ms-wax
.mka audio/x-matroska
.rtf application/rtf
.js application/javascript
.swf application/x-shockwave-flash
.class application/java
.tar application/x-tar
.zip application/zip
.gz application/x-zip
.gzip application/x-zip
.rar application/rar
.7z application/x-7z-compressed
.exe application/x-msdownload
.pot application/vnd.ms-powerpoint
.wri application/vnd.ms-write
.xla application/vnd.ms-excel
.xlt application/vnd.ms-excel
.xlw application/vnd.ms-excel
.mdb application/vnd.ms-access
.mpp application/vnd.ms-project
.docm application/vnd.ms-word.document.macroEnabled.12
.dotx application/vnd.openxmlformats-officedocument.wordprocessingml.template
.dotm application/vnd.ms-word.template.macroEnabled.12
.xlsm application/vnd.ms-excel.sheet.macroEnabled.12
.xlsb application/vnd.ms-excel.sheet.binary.macroEnabled.12
.xltx application/vnd.openxmlformats-officedocument.spreadsheetml.template
.xltm application/vnd.ms-excel.template.macroEnabled.12
.xlam application/vnd.ms-excel.addin.macroEnabled.12
.pptm application/vnd.ms-powerpoint.presentation.macroEnabled.12
.ppsm application/vnd.ms-powerpoint.slideshow.macroEnabled.12
.potx application/vnd.openxmlformats-officedocument.presentationml.template
.potm application/vnd.ms-powerpoint.template.macroEnabled.12
.ppam application/vnd.ms-powerpoint.addin.macroEnabled.12
.sldx application/vnd.openxmlformats-officedocument.presentationml.slide
.sldm application/vnd.ms-powerpoint.slide.macroEnabled.12
.onetoc application/onenote
.onetoc2 application/onenote
.onetmp application/onenote
.onepkg application/onenote
.odp application/vnd.oasis.opendocument.presentation
.ods application/vnd.oasis.opendocument.spreadsheet
.odg application/vnd.oasis.opendocument.graphics
.odc application/vnd.oasis.opendocument.chart
.odb application/vnd.oasis.opendocument.database
.odf application/vnd.oasis.opendocument.formula
.wp application/wordperfect
.wpd application/wordperfect
.key application/vnd.apple.keynote
.numbers application/vnd.apple.numbers
.pages application/vnd.apple.pages

Also Read,

Disallow Uploading of Specific File Types in WordPress