Permitted File Types for Uploading

Summary

This article details the permitted file types allowed for the File Uploads field. Note that this does not consider any additional restrictions placed by the form designer using the “Allowed file extensions” option, which will further limit allowed uploads.

What Is Permitted?

The File Upload field is limited in permitted file types by the WordPress core rules for file uploading. You can find more information on the official site and within WordPress codex documents like this one. Note the changes below though regarding WP 5.0.1!

Changes in WordPress 5.0.1, December 2018

Security changes released in WordPress 5.0.1 have changed the way uploaded files are validated, breaking some previously accepted file types. MIME Type validation is now performed, meaning that the content of uploaded files must now match their extension. WordPress states in this blog article that

“Most valid files should be unaffected, but there may be cases when a file needs to be renamed to its correct extension (e.g., an OpenOffice doc going from .pptx to .ppxs).”

With this change for example, the Microsoft Office Word file type .DOCX type will no longer validate properly, and will be rejected from uploading. The .DOC extensions may upload normally.

Note as mentioned in the article security patches are backported to the 3.7 branch, so these BC breaks also apply to versions 4.9.9, 4.8.8, etc.

Additional Info

Below are links for third-party plugins or information which can be used to modify permitted MIME types in file uploading. Use them at you own risk; Gravity Forms cannot guarantee their accuracy or effectiveness, especially noting that some of them were written prior to WordPress 5.0.1.

Third-Party Plugins

Mime Type Resources

If you’re looking to find the actual MIME type returned by certain applications, the MIME Type Checker includes a reference but also allows you to upload a file to pull out the MIME type.

WordPress core filters

When WordPress validation for the file type fails and the above third-party plugins can’t help, you can also try using the upload_mimes WordPress filter to implement your own solution.

You can find below a few examples:

// Add AI files mime type to WordPress.
add_filter( 'upload_mimes', function( $mime_types ) {
	$mime_types['ai'] = 'application/pdf'; // Adding .ai extension

	return $mime_types;
}, 1, 1 );
// Add MS Word .doc files mime type to WordPress.
add_filter( 'upload_mimes', function( $mime_types ) {
	$mime_types['doc'] = 'application/msword'; // Adding .doc extension

	return $mime_types;
}, 1, 1 );

If you need help to add snippets to your site, please check the following link for more details: Where Do I Put This Code?