WordPress restricts both file types and MIME types, with new types added via code updates. In this post, we will discuss what MIME types are, which MIME types WordPress permits to be uploaded, which MIME types WordPress recognizes, and how to add new MIME types if necessary.
We’ll also discuss why you could get a security error when uploading a picture, such as “Sorry, this file type is not permitted for security reasons,” and how to resolve it.
MIME types in WordPress here MIME stands for “Multipurpose Internet Mail Extensions.” Browsers and other internet devices utilize MIME types to identify the type of material on a page. For example, if you have a .png and a .jpeg file on the page, the browser will treat them as images rather than videos or other file types.
WordPress automatically stores a list of registered mime types in wp-includes/functions.php, which developers can access using wp_get_allowed_mime_types(). WordPress recognizes the following file types. However, not all MIME types recognized can be uploaded via the WordPress Admin Dashboard.
Use the upload_mimes filter to view only the sorts of files that WordPress supports for uploads.
If you try to upload a file with a MIME type or file type that WordPress does not support, you will see the error “Sorry, this file type is not permitted for security reasons.”Continue on to learn how to correct this issue.
Although WordPress recognizes a specific MIME type, it does not necessarily allow for uploading that file type on the Admin Dashboard. WordPress allows just the following file types to be uploaded.
The following is a list of the many file kinds that can be uploaded to WordPress, along with their matching MIME types. These file formats will upload without displaying any security warnings in your WordPress dashboard.
File Extension | MIME Type |
---|---|
.jpg | image/jpeg, image/pjpeg |
.jpeg | image/jpeg, image/pjpeg |
.png | image/png |
.gif | image/gif |
.ico | image/x-icon |
application/pdf | |
.doc | application/msword |
.docx | application/vnd.openxmlformats-officedocument.wordprocessingml.document |
.ppt | application/mspowerpoint, application/powerpoint, application/vnd.ms-powerpoint, application/x-mspowerpoint |
.pptx | application/vnd.openxmlformats-officedocument.presentationml.presentation |
.pps | application/mspowerpoint, application/vnd.ms-powerpoint |
.ppsx | application/vnd.openxmlformats-officedocument.presentationml.slideshow |
.odt | application/vnd.oasis.opendocument.text |
.xls | application/excel, application/vnd.ms-excel, application/x-excel, application/x-msexcel |
.xlsx | application/vnd.openxmlformats-officedocument.spreadsheetml.sheet |
.psd | application/octet-stream |
.mp3 | audio/mpeg3, audio/x-mpeg-3, video/mpeg, video/x-mpeg |
.m4a | audio/m4a |
.ogg | audio/ogg, |
.wav | audio/wav, audio/x-wav |
.mp4 | video/mp4 |
.m4v | video/x-m4v |
.mov | video/quicktime |
.wmv | video/x-ms-asf, video/x-ms-wmv |
.avi | application/x-troff-msvideo, video/avi, video/msvideo, video/x-msvideo |
.mpg | audio/mpeg, video/mpeg |
.ogv | video/ogg |
.3gp | video/3gpp, audio/3gpp |
.3g2 | video/3gpp2, audio/3gpp2 |
The wp_get_allowed_mime_types() function returns a list of MIME types that WordPress recognizes but does not allow for uploading. We’ll go over the MIME types that cannot be uploaded in wp-admin yet are recognized by WordPress.
When you upload a file with one of the following extensions, you will get the security warning: “Sorry, this file type is not permitted for security reasons.”Proceed to this section to discover how to fix the error.
File 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 |
With the WP Activity Log & Notifier, you have the power to customize and restrict the types of files users can upload to your WordPress site. This feature is crucial for maintaining your site’s security and preventing malicious code from being uploaded inadvertently.
image/jpeg
image/png
application/pdf
application/zip
video/mp4
By implementing these restrictions, you ensure that only the selected file formats are permitted for upload. All other types will be blocked, significantly reducing the risk of harmful files being uploaded to your site. This proactive approach to file upload management not only enhances security but also builds user trust by safeguarding sensitive data.
In conclusion, utilizing the WP Activity Log & Notifier to set up MIME type restrictions is an essential step towards a secure WordPress environment. By carefully selecting which file types users can upload and monitoring these uploads for any suspicious activity, you create a safer site that is less vulnerable to attacks. Implement these settings today to protect your WordPress site effectively!
0 comments