WordPress file type is not permitted for security reasons

This article explain little bit about uploading files to WordPress and its error when WordPress don’t allow some file types. WordPress by default allow users to upload following file types

Images

.jpg
.jpeg
.png
.gif
Documents

.pdf (Portable Document Format; Adobe Acrobat)
.doc, .docx (Microsoft Word Document)
.ppt, .pptx, .pps, .ppsx (Microsoft PowerPoint Presentation)
.odt (OpenDocument Text Document)
.xls, .xlsx (Microsoft Excel Document)
Audio

.mp3
.m4a
.ogg
.wav
Video

.mp4, .m4v (MPEG-4)
.mov (QuickTime)
.wmv (Windows Media Video)
.avi
.mpg
.ogv (Ogg)
.3gp (3GPP)
.3g2 (3GPP2)

filetypeerror

WordPress will show security warning like this, “Sorry, this file type is not permitted for security reasons.” when we try to upload other file formats. This security warning also show when some web hosts are not permitted above file formats to be uploaded

The easiest way to override this restriction is by adding following to wp-config.php, this constant all all file types to be uploaded to WordPress

define('ALLOW_UNFILTERED_UPLOADS', true);

You could use following function to allow specific file types

add_filter('upload_mimes', 'pixert_upload_types');
function pixert_upload_types($existing_mimes=array()){
$existing_mimes['flv'] = 'video/x-flv';
$existing_mimes['mid'] = 'audio/midi';
return $existing_mimes;
}

If you have set file types you could add new file types to Upload Settings in WordPress Multisite/Network, this setting allow sub-domain to upload new file types

Go to WP-Admin > My Sites > Network Admin > Settings > Upload Settings, add mp4 to Upload file types (jpg jpeg png gif mp3 mov avi wmv midi mid pdf mp4 ) (32MB)

Summary
Article Name
WordPress file type is not permitted for security reasons
Description
Fix error file type is not permitted on WordPress Network/Multisite
Author
  • sykat

    It is a relief

  • Just what I was looking for – thanks for providing such clear instructions. Much appreciated.

  • J.R. Noble

    I don’t have multiple websites. Where can I locate this file so I can make the changes to the file extension permissions? Can I find the settings in the CPanel or in the WordPress dashboard?