Allow loading any type of WordPress

Let's try to allow WordPress to upload any file types. Initially, WordPress does not provide such an opportunity to protect the site., but sometimes you may need to load a non-standard format.

For starters, a simple and not the best way. There is a plugin for WordPress Role Manager but this plugin gives the rights to upload any files, and it's dangerous.

Consider another way to allow uploading your file types. In the following example, I will allow PHP to be loaded, XHTML и Htaccess. Unusual yes ).
The parameters I specified in the code are passed to an array of allowed MIME types. The result can be seen in the picture..
upload-filter загружаем нужный тип MIME файлов в WordPress

And here is the code of our type filter itself.

Description of types, that WordPress supports by default can be found at wp-includes/functions.php.

Your list should only contain file types, which are clearly needed, otherwise above constants can be used by attackers.

Here's another souvenir, plugin to allow new types to be loaded.

mime type wordpress

Share your experience of using it in the comments. I haven't gotten around to testing the plugin yet..

Nikolaenko Maxim

Director of web studies ProGrafika. I am developing, website design and promotion. Always glad to new blog readers and good clients.


You may also like...

2 Responses

  1. Vit says:

    Thanks for the material! Why is WordPress not allowed to upload SVG files?? If I allow it, how will it affect security?

    • Nikolaenko Maxim says:

      Limit downloads to a specific user only, this will give more headaches to those who decide to break your site.
      if ( is_user_logged_in() ) {
      $current_user = wp_get_current_user();
      if ( 1 == $current_user->ID ) {
      // do staff.
      } else {
      // do staff.
      }
      }

      Specifically, I did not encounter this type of file when uploading, but I think after permission you should not forget about regular backups and CMS updates. I think WP is just limiting the upload of rarely used file types..

      I'm glad you liked the lesson., if you have any questions write.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Templates for WordPress
The best hosting in Ukraine
Stable hosting for Drupal