How to upload docx file in wordpress?

Issue: Can’t upload .docx files (sorry, you’re not allowed to upload this file type) in wordpress

If you’re encountering an issue where you’re unable to upload .docx files in WordPress and receiving the error message “sorry, you’re not allowed to upload this file type,” it’s likely due to the file type restrictions set by your WordPress installation. By default, WordPress restricts certain file types for security reasons.

To enable the upload of .docx files in WordPress, you can follow these steps:

  1. Install and activate a plugin: One way to allow additional file types is by using a plugin. There are several plugins available that can help you manage file type restrictions. One popular option is the “Disable Real MIME Check” plugin. Install and activate the plugin from the WordPress Plugin Directory.
  2. Configure the plugin settings: After activating the plugin, go to the “Settings” section in your WordPress dashboard and look for the plugin’s settings page. Depending on the plugin you installed, it might have different settings, but usually, you’ll find an option to allow specific file types. Locate the .docx file type and ensure it is enabled or add it to the allowed file types list.
  3. Save changes and test: Once you have made the necessary changes in the plugin settings, save the settings, and try uploading a .docx file again. It should now be allowed.

If you prefer not to use a plugin, you can modify the WordPress configuration directly, but it requires editing the theme’s functions.php file or creating a custom plugin. Here’s an example of how you can add support for .docx files using code:

function custom_upload_mimes($mimes) {
    $mimes['docx'] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
    return $mimes;
}
add_filter('upload_mimes', 'custom_upload_mimes');

Add this code to your theme’s functions.php file or create a custom plugin by creating a new PHP file with the code and uploading it to the /wp-content/plugins/ directory. Remember to save the changes and test the file upload afterward.

Please note that allowing additional file types can have security implications. Make sure you trust the files you’re allowing to be uploaded, and be cautious when accepting file uploads from users on your website.

Similar Posts