WordPress allows its users to upload and use a variety of files with different formats. But while uploading files with format other than image files, it reflects this annoying error warning most of the times:
Sorry, this file type is not permitted for security reasons.
Below is the screen capture of the error produced in the real time when I tried uploading a *.swf file to my WordPress media library:
WordPress Multisite provides a way to fix it up from the Upload settings, but a generic WordPress installation doesn’t have any such options to get rid of this error.
Fixing the Error
Note that clicking on “Dismiss Error” and uploading again is not going to fix it at all. Here is the real and tested 2-step fix that should solve the problem:
- Copy and paste the below line of code in the
wpconfig.php
file of your WordPress installation:define('ALLOW_UNFILTERED_UPLOADS', true);
Now go back to media library and try uploading the media that showed the error earlier before. If it gets uploaded successfully, you won’t need anything else. But else, continue to the next step.
- Add the below give code to the
functions.php
file of your WordPress theme and save the changes:add_filter('upload_mimes', 'pixert_upload_types'); function pixert_upload_types($existing_mimes=array()){ $existing_mimes['mp4'] = 'video/x-mp4'; $existing_mimes['swf'] = 'video/x-swf'; $existing_mimes['flv'] = 'video/x-flv'; $existing_mimes['mid'] = 'audio/midi'; return $existing_mimes; }
[*] You may add more mime types for different file formats in the above code as per your need.
Now again, retry uploading that file. The error should get fixed by now.
If you’re still seeing an error, leave a comment below. I’ll be happy to help you with that. Thanks.