File upload security means checking and storing files that strangers send to your website, so they cannot cause harm.
This guide is for site owners, new developers and anyone whose website has a "send us a file" button. You do not need to write code to be affected: if customers can send photos, CVs or documents through your site, those files need care.
In short
- An upload form lets strangers put their own files on your server, so treat every file as untrusted.
- A harmful file can try to run as a program, fill up your storage, or attack the people who open it.
- Accept only the file types you need, check the contents as well as the name, and limit the size.
- Give each file a new name, scan it, and store it where the website cannot run it.
What you will learn
- Explain why an upload form is a way in to your server.
- Spot the warning signs in a list of uploaded files.
- Check the five basic protections with your web supplier.
- Ask staff to take care when they open files sent by the public.
- Send-a-file box (upload form)
- a part of a website that lets visitors send files, such as photos or CVs.
- Approved list (allowlist)
- a short list of the only things that are let through, with everything else refused.
- Harmful software (malware)
- a program made to damage, spy on or take over a computer.
What is file upload security?
Think of a cloakroom at a busy event. Strangers hand over bags, and staff take them in. Good staff check the size, give each bag a ticket and keep the bags in a back room, well away from the kitchen.
An upload form is your website's cloakroom. Every file comes from someone you do not know. A leading web security charity says uploaded files are a significant risk to websites.[1]
File upload security is the set of checks a site makes on each file. It covers what is allowed in, how big it can be, what it is called and where it is kept.
Where the comparison stops working: a bag in a cloakroom stays shut. An uploaded file may be opened by the website, by software that makes thumbnails, or by your staff. Each of those is a chance for a harmful file to act.[2]
Why does it matter?
An upload can be the first step of an attack. Once a harmful file is on the server, the attacker only needs a way to make it run.[1]
If you own a website with an upload form
What could happen: a file disguised as a photo runs as a program and gives a stranger control of your site.
Check this: ask your supplier whether the upload folder can run programs. The answer should be no.
If you are a new developer
What could happen: you trust the file name and type the browser sends, and both turn out to be made up.
Check this: check what the file really contains, and give it a new name you choose.
If you open files sent through your website
What could happen: a "CV" from the careers form carries harmful software or a link to a fake login page.
Check this: open public files only after they have been scanned, and never enable macros.
Next: Malware for Beginners
What does it look like?
Here is a made-up list of files sent through a vet practice's "send us your pet's records" form in one week.
Example only. All values are made up.
# uploads folder, lindenvets.example.com bella-vaccines.pdf 220 KB (1) max.jpg 1.4 MB records.pdf.exe 310 KB (2) cat-photo.jpg 4.0 GB (3) ..%2F..%2Fsettings.txt 1 KB (4) report.html 12 KB (5)
- A normal file of a type the form expects.
- A program pretending to be a document. The last part of the name counts.
- Far too big for a photo. Huge files can fill the server's storage.
- In a real file name, odd characters like these could try to save the file over another one.
- A web page, not a record. If the site shows it to others, it may trick their browsers.
Why this is risky: the form takes any name, type and size. It keeps files where the website can open them.[2]
The safer way: the form accepts only PDF and image files under a set size. Each file gets a new name, is scanned and is stored away from the website.
How does it work?
A safe upload form puts each file through a set of checks, in order. The same charity's advice covers each of these steps.[2]
- Who is sending? Where it fits the job, only signed-in, approved users can upload.
- Is the type allowed? The site keeps an allowlist of the few file types it needs, such as PDF and JPG, and refuses the rest. It checks the contents too, because the name and the type label the browser sends can both be faked.
- Is it a sensible size? The site sets a maximum size, so one file cannot fill the storage.
- New name. The site throws away the sender's file name and gives the file a random one of its own.
- Scan. Where possible, the file is checked for malware before anyone can download or open it.
- Store safely. The file is kept outside the website's own folders, or on a separate service, where it cannot run as a program.

No single check is enough on its own. File type checks can be fooled, and scanners can miss new threats.[2] Layers matter, so that if one check fails another still helps.

A worked example
Marek Mbeki is practice manager at Linden Vets, a fictional vet practice. Last year the practice added a form so pet owners could send vaccine records and photos before appointments.
One Monday, the reception computer warns that a file called records.pdf.exe has been blocked. It came through the form. Nobody opened it, but Marek wants to know how it got that far.
He thinks of the cloakroom. The form had been taking in any bag, of any size, and putting it straight in the kitchen.
He calls the practice's web developer and asks five questions. Which file types does the form accept? Is there a size limit? Are files renamed? Are they scanned? Where are they kept?
The answers are not good. The form accepts any type, has no size limit, and saves files inside the website's own folder.
The developer makes changes that week. The form now accepts only PDF, JPG and PNG files up to a set size. It checks the contents, not just the name. Each file gets a random name, is scanned, and is stored on a separate storage service that cannot run programs.[2]
The developer also checks the upload folder for anything that should not be there. They find nothing unexpected in the files they reviewed.
Marek adds a line to the staff guide: open files from the website only from the practice system, never from a personal device.
Myths and mistakes
| What people think | What is true |
|---|---|
| If the name ends in .jpg, it is a picture. | The name and type label can be faked. Check the contents too.[2] |
| Blocking a few dangerous types is enough. | Lists of banned types are easy to get round. Allow only the few types you need.[2] |
| Checking files in the browser keeps us safe. | Checks in the visitor's browser help honest users. Attackers can skip them, so the server must check again. |
| A virus scanner catches every bad file. | Scanning helps, but it is one layer. Renaming, safe storage and type checks still matter. |
| Only big companies are targeted through uploads. | Automated tools look for upload forms on sites of every size. |
What can I do this week?
- List every form on your site that accepts files.
- Ask your supplier the five questions: types, size, renaming, scanning and storage.
- Remove upload forms you no longer use.
- Remind staff to open files from the public only after they have been scanned.
Checklist
- Each upload form accepts only the file types the business needs.
- The server checks the contents of each file, not just its name.
- There is a maximum file size, and it suits the job.
- Files are given new names chosen by the site.
- Files are scanned before staff or customers can open them, where possible.
- Uploads are stored where they cannot run as programs.
- Only people who need to can upload, view or download the files.
- Unused upload forms have been removed.
Common questions
Why is letting users upload files risky?
Because you are letting strangers put files on your server. A harmful file may try to run as a program, fill your storage, overwrite other files or attack people who open it later. The checks on this page reduce each of those risks.
Is checking the file extension enough?
No. The extension is just part of the name, which the sender chooses. Use an allowlist of extensions, but also check what the file really contains, rename it and store it safely. Each check covers gaps in the others.
Where should uploaded files be stored?
Away from the website's own folders, ideally on a separate storage service. The place where files are kept should not be able to run programs. The website then hands files out only to people who are allowed to see them.
What is a web shell, and how does it relate to uploads?
A web shell is a small harmful program that gives an attacker remote control of a web server. A careless upload form is one common way it gets there. See the Web Shell Response Playbook.
Where next?
Ready for the detail? Read the practitioner guide: File Upload Security Guide. It goes further into the full validation pipeline, archives and document formats, malware scanning and how to detect upload abuse.
Also useful:
- Secure File Upload Handling Guide
- Web Shell Response Playbook
- Website Security for Beginners
- Malware for Beginners
Related NHI Mgmt Group resources: Web Application Firewalls for Beginners · Secure File Sharing for Beginners · Command Injection for Beginners
Key terms
- Upload form
- A part of a website that lets visitors send files to the server.
- Allowlist
- A list of the only things that are allowed, with everything else refused.
- MIME type
- A label that says what kind of file something is. The sender can fake it.
- Malware
- Software made to damage, spy on or take over a computer.
- Web shell
- A harmful program on a web server that lets an attacker control it from afar.
- Least privilege
- Giving people and programs only the access they need, and no more.
Sources and further reading
- Unrestricted File Upload. OWASP Foundation. https://community.owasp.org/vulnerabilities/Unrestricted_File_Upload, accessed 28 Nov 2026.
- File Upload Cheat Sheet. OWASP Cheat Sheet Series, OWASP Foundation. https://cheatsheetseries.owasp.org/cheatsheets/File_Upload_Cheat_Sheet.html, accessed 28 Nov 2026.