WordPress has built-in media uploader or file uploader which allows user to directly upload the files to the server via online inline interface without having to use a FTP or SFTP client, and subsequently allows user to manage the media and files. However, for security purpose, WordPress restricts the file types which you could upload using the built-in multi-file uploader or browser uploader.

By default, WordPress only allows the following file types to be uploaded via its uploader:

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)
  • .zip (Compressed Folder)

Audio

  • .mp3
  • .m4a
  • .ogg
  • .wav

Video

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

If you try to upload other file formats, you will get a security warning message instead, which states that “The file has failed to upload due to an error,” and “Sorry, this file type is not permitted for security reasons.”

WordPress Upload Error
WordPress Upload Error

There are several ways to workaround and resolve the WordPress upload error due to file types restriction. Use one of the guide presented in the tutorials to override the WordPress upload restriction and allow all or selected file types to be uploaded using the media uploader.

Allow All File Types to be Uploaded via WordPress Uploader

The easiest way to override WordPress file type restriction when uploading using inline uploader is by defining a constant in wp-config.php. To do so, edit the wp-config.php located in the root of your WordPress installation via SSH or Telnet, and add the following line:

define('ALLOW_UNFILTERED_UPLOADS', true);

Allow Some Specific or Selected File Type to be Uploaded via WordPress Uploader

If you want to expand and include additional file types and extensions that are supported by WordPress inline uploader, you can do so by adding a custom WordPress hook as shown in code below in the active theme’s functions.php file.

If supported by proper file permissions, you can edit the theme’s functions.php file via Appearance -> Editor. Otherwise, SSH or Telnet to your WordPress installation.
function extended_upload_mimes ( $mime_types =array() ) {
   $mime_types['msg'] = 'application/vnd.ms-outlook';
   $mime_types['reg'] = 'text/reg';
   $mime_types['ps'] = 'application/postscript';
   $mime_types['flv'] = 'video/x-flv';
   $mime_types['mid'] = 'audio/midi';
   // The above MIME types are just example, add as many as you like the
   // MIME types (file types and extensions) that you want WordPress to 
   // allow.

   // If you want to remove existing file types (do not allow it to be 
   // uploaded, use the following code. You can include as many as you 
   // like to restrict the file extensions which are otherwise allowed 
   // by default.
   unset( $mime_types['exe'] );

   return $mime_types;
}
add_filter('upload_mimes', 'extended_upload_mimes');

Alternative
You can make sure of WordPress plugins to configure extra mime-types for support by the inline-uploader. Here’s some of the plugins that extend the file types allowed by WordPress inline media uploader.

  1. PJW Mime Config
  2. AP Extended MIME Types – supports WordPress Multisite

Related Posts

  • I just ran into this problem uploading a midi file but now it’s fixed, thanks a lot
    And no, I promise it won’t be used as a background song for my blog ;D

    Whatever happened to midis playing in the background of pages anyways?