WordPress 5.0.1 MIME validation for uploaded files fix for wp_handle_sideload()

Sorry, this file type is not permitted for security reasons due to WordPress 5.0.1 MIME validation for uploaded files fix for wp_handle_sideload()

If you have used function wp_handle_sideload() in any of your plugin/theme then you need to pass the mimes types too.

Because WordPress 5.0.1 Security Released. In which the uploaded files are validated with the real MIME type.

E.g. If you have set the application/xml MIME type though filter upload_mimes to upload the XML file and if the real MIME type of uploaded file is text/xml then the file was not uploaded. And it shows the below message.

Sorry, this file type is not permitted for security reasons.


To fix this you need to set the mimes for function wp_handle_sideload().

Check below code for reference.

For more details visit:

https://make.wordpress.org/core/2018/12/13/backwards-compatibility-breaks-in-5-0-1/

https://wordpress.org/news/2018/12/wordpress-5-0-1-security-release/

Author: Mahesh Waghmare

I'm a professional WordPress theme/plugin developer since 2012 from Pune, India.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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