Why does this error happen?
WordPress keeps a list of file types it trusts. For example, it accepts JPG pictures and PDF files. If your file is not on the list, WordPress blocks it. It shows the message "Sorry, you are not allowed to upload this file type."
This protects your site. Some files can carry harmful code. But sometimes you really need a file type that is not on the list, such as SVG or a font file.
Fix 1: Check the file first
- Look at the end of the file name, such as
.jpgor.svg. This end part is the extension. - Make sure the file is not damaged and has the right extension.
- Try again. Sometimes a simple rename solves it.
Fix 2: Use a plugin
A plugin is an add-on for WordPress. Some plugins let you allow more file types without code.
- Log in to your WordPress dashboard.
- Go to Plugins, then Add New.
- Search for a plugin that manages upload file types.
- Click Install Now, then Activate.
- Open the plugin settings and add the file type you need.
- Try your upload again.
Fix 3: Add a line of code
You can also allow a type with code. This goes in the functions.php file of your theme. A theme controls how your site looks. Better still, use a child theme or a code snippets plugin, so an update does not erase your change.
- Log in to your hosting control panel and open File Manager.
- Go to
wp-content/themesand open your theme folder. - Edit
functions.php. - Add this code at the end of the file:
function my_custom_mimes( $mimes ) {
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
add_filter( 'upload_mimes', 'my_custom_mimes' );
This code tells WordPress to accept SVG files. Change the type to match the file you need.
- Save the file and try the upload again.
Fix 4: Try the multisite note
On a WordPress Multisite network, the main admin controls file types. Look in Network Admin, then Settings, and check the "Upload file types" box.
Quick recap
- WordPress blocks file types it does not trust.
- Check the file name and extension first.
- Use a plugin or a small code snippet to allow the type.
- Only allow files you trust, and back up first.