If you’re receiving an error in WordPress that says “Sorry, this file type is not permitted for security reasons,” don’t worry. This error is usually caused by WordPress’s security settings, which are designed to prevent potentially harmful files from being uploaded to your site.
Here are the steps to fix this error:
Step 1: Check the File Type Make sure the file you are trying to upload is not on the list of file types that are not allowed by WordPress. To check the file types that are allowed, go to Settings > Media from the WordPress dashboard. In the “Uploading Files” section, you’ll see a list of file types that are allowed. If the file type you’re trying to upload is not on this list, you can add it by following the steps below.
Step 2: Edit the Functions.php File To add a new file type, you need to edit your WordPress theme’s functions.php file. To do this, follow these steps:
- Log in to your WordPress site.
- Go to Appearance > Theme Editor.
- Select the functions.php file from the list of files on the right.
- Add the following code to the end of the file:
phpCopy codefunction add_custom_upload_mimes( $existing_mimes ) {
$existing_mimes['file_extension'] = 'mime_type';
return $existing_mimes;
}
add_filter( 'upload_mimes', 'add_custom_upload_mimes' );
Replace "file_extension" with the extension of the file you want to add (e.g. "pdf", "docx", etc.) and "mime_type" with the MIME type of the file. You can find the MIME type of the file by searching online.
Step 3: Save the Changes Once you’ve added the code to the functions.php file, click on the “Update File” button to save the changes.
That’s it! You should now be able to upload the file type you added to your WordPress site without receiving the “Sorry, this file type is not permitted for security reasons” error.