Australian cloud for business software — built and run in Sydney since 2002

NetLeverage
NetLeverage

WordPress "Sorry, you are not allowed to upload this file type.": the allowed list, the content check and the user's rights

Technical article
Hosting

About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.

WordPress shows "Sorry, you are not allowed to upload this file type." when a file fails one of three tests: its extension is not on the list of allowed types, its real content does not match that extension, or the signed-in user lacks the right to upload that kind of file. The message is not about file size or the server's disk, which have their own messages. Find which test failed before you add anything to the allowed list, because the content test still applies after you add a type.

What the error means

WordPress 6.7.1 has the same sentence in three places.

  • The browser. script-loader.php registers it as invalid_filetype, and wp_plupload_default_settings() in media.php gives the upload script an extension filter built from get_allowed_mime_types(). In the handlers, a Plupload FILE_EXTENSION_ERROR shows that text. Our own reading: a file with an extension that is not allowed is refused before it is sent.
  • The server, for an upload. wp_handle_upload() in wp-admin/includes/file.php calls wp_check_filetype_and_ext(). If the type or extension comes back empty and the user lacks the unfiltered_upload capability, it returns this message.
  • The server, for a file created from content. wp_upload_bits() in wp-includes/functions.php checks the name with wp_check_filetype() and returns the same message.

wp_check_filetype_and_ext() first matches the file name's extension against the allowed list. For images it then reads the file to find the real image type. For other files, when the PHP fileinfo extension is loaded, it reads the content type and compares it with the type the extension gave. The code treats a mismatch as dangerous and clears the type and the extension, and that gives this message even though the extension was on the list. It allows a few specific exceptions, for example text files that PHP reports as text/plain for CSV and similar types.

The allowed list comes from get_allowed_mime_types(). Reading the 6.7.1 source: it starts from wp_get_mime_types(), always removes swf and exe, removes htm|html and js unless the user has unfiltered_html, and then applies the upload_mimes filter. The developer reference describes that filter as one that "Filters the list of allowed mime types and file extensions."

Likely causes

Cause What you see How to confirm
The extension is not in the default list (for example dwg, json or sql) The message appears at once, before a progress bar The extension is missing from wp_get_mime_types() in the 6.7.1 source, and no plugin or theme adds it
A plugin or theme code removes a type with upload_mimes A type that worked before now fails A search of wp-content for upload_mimes finds a filter that unsets it
The extension is on the list but the content is another type (a renamed file) The file is sent, then refused The file does not open in the program its extension implies
The user lacks unfiltered_html and the file is .html, .htm or .js Only these types fail, only for some users The roles page: single-site Administrators and Editors have unfiltered_html; on Multisite, Super Admins only
Multisite: the type is missing from the network's Upload file types A type that the default list allows fails on every site The network setting does not list the extension
The file is .exe or .swf Refused for a user without unfiltered_upload get_allowed_mime_types() removes both

Prove the cause before changing anything

All of these steps only read.

1. Find where the message appears. Open the browser's Network panel before you upload. Chrome's DevTools reference says the panel records requests while DevTools is open, and that Preserve log keeps requests across page loads. Upload the file and look for a request to async-upload.php. Our own reading: no request means the browser's extension filter refused the file, and a request that returns the message means a server test did.

2. Name the extension exactly. Our own reading of wp_check_filetype() in the 6.7.1 source: the check looks at the end of the file name, so plan.v2.dwg is judged by dwg.

3. Compare it with the default list. In wp_get_mime_types() at tag 6.7.1, the list covers common image, video, audio, text, document, archive and Office types. json, xml, svg, sql and dwg are not in it.

4. Look for code that changes the list. Search the plugin and theme folders for the filter name. The grep(1) Linux manual page says -r will "Read all files under each directory, recursively, following symbolic links only if they are on the command line." and -n will "Prefix each line of output with the 1-based line number within its input file."

grep -rn "upload_mimes" wp-content/plugins wp-content/themes

No lines means nothing in those folders edits the list. Lines show the file to read.

5. Check the user. For .html, .htm or .js, check whether the signed-in user is a role that has unfiltered_html.

6. On Multisite, read the network setting. Open Settings > Network Settings in the Network Admin and find Upload file types under Upload Settings. Write down its current value and the time.

Fix

Add a type that the default list lacks

WordPress documents the upload_mimes filter with the parameters array $t (mime types keyed by the file extension regex) and int|WP_User|null $user. Our own example, written to that documented signature, adds dwg. The type string image/vnd.dwg is our own example, so use the type string your files carry.

First save the current state. POSIX cp with -p duplicates "The time of last data modification and time of last access" of the source file in the copy.

cp -p wp-content/themes/example-child/functions.php wp-content/themes/example-child/functions.php.2026-12-04

Risk: the next edit adds PHP code to a theme file that runs on every page request. A typing mistake can stop the whole site with a critical error, and the new type becomes uploadable by every user who may upload files. Make the edit when traffic is low.

Add this to the file:

add_filter( 'upload_mimes', function ( $mimes ) {
	$mimes['dwg'] = 'image/vnd.dwg';
	return $mimes;
} );

Only if you need to back out: copy the saved file back over functions.php. The added type is lost and any other edit made since the copy is lost too. Then try the upload again to see the state you went back to.

Risk: the next command overwrites functions.php with the copy saved before the edit.

cp -p wp-content/themes/example-child/functions.php.2026-12-04 wp-content/themes/example-child/functions.php

If a mistake in the file has already taken the site down, see WordPress "There has been a critical error on this website": read the PHP error, then fix the cause.

Multisite: add the extension to the network setting

The network documentation says adding a type in the Upload file types field will not work for types outside the default set unless the upload_mimes filter also adds them. Our own reading of check_upload_mimes() in ms-functions.php: it keeps only the extensions named in the network setting, so for a type the default set already holds, the field is enough.

First save the current state: write down the current value of Upload file types and the time.

Risk: the next change applies to every site in the network at once, and it widens which files all site users can upload.

In the Network Admin, go to Settings > Network Settings, add the extension to Upload file types and save.

To undo it: set the field back to the value you wrote down and save. Files uploaded in the meantime stay in the Media Library. Then try the upload again to check.

The file does not match its extension

Do not rename the file. Save or export it again from the program that made it, in the format its extension names, then upload the new file. Our own reading: the content check compares the real content with the extension, so a renamed file keeps failing.

The user lacks the right for .html or .js

The roles page says "Enabling this option for untrusted users may result in their posting malicious or poorly formatted code." Our own advice: have a user who already has unfiltered_html upload the file. WordPress also has a constant, ALLOW_UNFILTERED_UPLOADS, that grants unfiltered_upload, and the code in wp_handle_upload() does not return this message to a user who holds it. Our own advice: do not use it for this fault, because it lifts the type check for every upload by a user who holds it.

Example (illustrative): on web01, a designer at Example Pty Ltd uploads site-plan.dwg to www.example.com. The message appears before any progress bar, and the Network panel shows no request to async-upload.php. dwg is not in the default list, and the search for upload_mimes finds nothing. The administrator saves the child theme's functions.php, adds the filter above, and the browser accepts the file. If the message then returned after the file was sent, the content check would be the next thing to look at.

Confirm the fix

  1. Upload the file again in Media > Add New. The message should not appear in the browser or after the upload.
  2. Upload a file type that was already allowed, such as a JPEG, to check that the list still works.
  3. Try the same file as a user with a lower role, if that is who needs it, because the rights test applies per user.

What to watch afterwards

  • Add only the types you need, one at a time, and note why. Every added type is another kind of file the site accepts from users who can upload.
  • Our own advice: after a theme change, repeat the upload test, because code in a theme's functions.php only runs while that theme is active.
  • On Multisite, keep the network list and the filter in step.

Risks and limits

  • These commands have not been run or lab-tested.
  • Adding a type does not change the content check. A file whose real content differs from the type string you gave can still be refused.
  • The paths and the dwg type string are examples. Other WordPress versions may hold a different default list.
  • Upload size and temporary-folder messages are separate faults: see WordPress "Missing a temporary folder.": PHP cannot create the upload's temporary file.

Sources