You must control the files that users upload to your WordPress site for both security and simplicity. Controlling uploads helps stop unsafe programs, reduce risks, and maintain site compatibility. This guide provides a straightforward way to manage and control file types uploaded to your site.
Understanding the importance of limiting file uploads in WordPress is crucial. By default, WordPress allows images, document files, audio files, and video files to be uploaded. Although convenient, this flexibility might pose risks if not managed correctly.
By default, WordPress supports these file types:
If your website doesn’t need some of these, consider restricting them.
There are several methods to restrict file types, depending on your technical expertise and project needs.
Always create a full backup before making any changes to your WordPress site—especially when altering core behavior or installing new features. Backups protect your data and ensure you can restore your site if anything goes wrong. Consider using plugins like:
List the file types you want users to upload, which may vary by site type:
Having this list ready makes configurations clearer and more focused.
upload_mimes
Filter in functions.php
The most direct way to limit file types is by using the upload_mimes
filter in your theme’s functions.php
file.
How to do it:
functions.php
.What this does:
Overrides the default list of allowed file types and sets a custom list.
If you’re not comfortable editing theme files, plugins offer an easier method. Popular choices include:
You might allow certain file types for admins while restricting them for contributors or subscribers. This ensures sensitive or risky formats, like executable files, are kept away from general users. Meanwhile, it allows admins to manage these file types as needed, balancing security and functionality.
.htaccess
for Server-Level RestrictionsOn Apache-based servers, the .htaccess
file can add an extra restriction layer:
<FilesMatch "\.(exe|php|sh|bat|pl)$">
Order Deny,Allow
Deny from all
</FilesMatch>
This prevents access to potentially dangerous file types, even if they’re uploaded.
After setting restrictions:
Testing ensures your site functions as expected with user-defined rules.
Plugins like Wordfence or Sucuri Security can scan uploads for malware or anomalies.
Control file sizes using php.ini
or .htaccess
:
upload_max_filesize = 2M
post_max_size = 3M
Prevent file conflicts or attacks using plugins like “Media File Renamer” to rename files upon upload.
Never allow scripts or executables (e.g., .php, .exe) to be uploaded—even by admins.
File uploads can be convenient, but prioritizing security is essential to avoid issues. By following this guide, you can restrict file uploads effectively and address common concerns. Keeping your software updated and reviewing your site’s security settings regularly will further secure your website and its users. Thank you for reading our guide on restricting file uploads in WordPress. We hope it helps you manage your website’s security effectively.
Learn what a TIFF file is, how it compares to other formats like JPEG and PNG, and why it’s used in photography, printing, and design. Also covers its pros, cons, and conversion tips.
Discover the seven best WordPress help desk plugins to boost your customer support and manage tickets easily and efficiently.
Explore the 16 best WordPress comment plugins in 2025 to improve interaction, reduce spam, and build a strong user community.
Explore the top 10 WordPress admin dashboard plugins to enhance usability, customize layouts, and manage user access effortlessly.
Discover the best free WordPress slideshow plugins to boost your website's visual appeal with stunning and interactive sliders.
Learn how to move WordPress comments between posts using a plugin, bulk edit, or code method—easy steps for all skill levels.
Learn how to change the creation date of a file on Windows using various methods, including third-party tools and command-line utilities.
Add an advanced search box in WordPress using Facetious. Improve user experience with smart filters for faster, precise results.
Easily display Instagram photos in your WordPress sidebar with plugins. Boost site appeal, engagement, and social media growth.
How to open DAT files easily on Windows or Mac by following these steps and using the right tools to uncover their content.
Learn how to set a maximum number of tags in WordPress posts using simple steps, plugins, or custom code to manage content better.
Easily manage WordPress pages with the Nested Pages plugin. Use drag-and-drop, tree view, and menu sync to organize content efficiently without coding.