🎉 Celebrate with 10% OFF on All Products! Use Code: GFEX10 Or Buy Any 2+ Items for 30% OFF with Code: GFEX30!
Guides & Tutorials October 22, 2026

How to Scan Gravity Forms File Uploads for Viruses Before They Are Saved

GravityExtra
How to Scan Gravity Forms File Uploads for Viruses Before They Are Saved

A File Upload field makes a form useful and makes your site a target. A job application form takes a resume, a support form takes a screenshot, an insurance form takes a scan of a document. Each of those is a file from a stranger that lands on your server and is opened by someone on your team. Most files are harmless. One in a long while is not, and a macro in a document or a script in a download can be enough to start a bad week.

Gravity Forms gives you good basic controls for uploads, and this guide shows what they do, where they stop, and how to add a real virus scan that runs before the entry is saved. We will use the Gravity Forms Upload Virus Scan Premium Add-on, and explain the three scanners it can use so you can pick the one that fits your hosting and your privacy rules.

What Gravity Forms Already Does With Uploads

A File Upload field lets you list the allowed extensions, set a maximum size and a maximum number of files. Gravity Forms also checks the file type against WordPress rules and renames files into a folder with a hard-to-guess name. Those are useful, but they all look at the outside of the file: its name, its type and its size. None of them looks at what is inside.

A document with an allowed extension can still hold a malicious macro. An image can hide a script in its data. A zip is a box with unknown content. To catch these you need a scanner that knows the signatures of bad files, and you need to run it at the right moment.

Why the Moment of the Scan Matters

The best moment is when the form is validated, before the entry exists. At that point you can refuse the submission, delete the temporary file and tell the visitor, and nothing infected is ever stored next to your entries or linked from a notification e-mail. If the scan runs later, a file may already be in your uploads folder, in an e-mail attachment and in an export before anyone notices.

A Gravity Forms form with a File Upload field after an infected file was sent: a red box says there was a problem and the Document field shows the message that the file looks unsafe
An infected file is refused with the message you wrote, and it is not listed again on the form.

That is how the add-on works by default. The file is scanned when the field is validated. A clean file passes. An infected one makes the field fail with the message you wrote, the temporary file is deleted and the form is shown again, without the file. It works for a single file, for the multiple file uploader, and for files that were sent on an earlier page of a multi-page form.

Three Ways to Scan: Pick the One That Fits

Option 1: ClamAV on Your Own Server

ClamAV is the free, open source antivirus that many servers already run. It runs as a daemon called clamd. The add-on connects to it over a local socket or over TCP and streams the file with the INSTREAM command, so the file does not have to be written anywhere else. If there is no daemon, it can run the clamscan program once for each file, which is slower because the program loads its signature database every time.

The big advantage is privacy: the files never leave your server. The big limit is availability: shared hosting almost never offers ClamAV, and it needs memory for its signature database. If you manage your own server or your host offers ClamAV, this is the best choice. If not, the add-on tells you so when you press Test connection, and you can move on to a cloud scanner.

Option 2: Cloudmersive

Cloudmersive offers a virus scan API with a self-service key. The add-on sends the file to the scan endpoint with your key in a header and reads the answer, which is either clean or the name of the virus. You need no server software, so it works on any host. The price of that convenience is that the whole file travels to Cloudmersive, and the free plan has limits on the number of calls and the size of a file. Check the plan against your traffic and set the largest file in the add-on to match.

Option 3: VirusTotal

VirusTotal runs a file through dozens of engines. The add-on can use it in two ways. In fingerprint mode it sends only the SHA-256 of the file, which cannot be turned back into the file, and reads the last report. Known malware is caught. A file that VirusTotal has never seen cannot be judged, and you choose whether to let it in with a flag or to refuse it. In upload mode the add-on uploads unknown files, up to 32 MB, and waits for the analysis, but an uploaded file becomes visible to VirusTotal and its partners, so use that mode only for files you could share.

The free public key allows 4 requests a minute and is meant for non-commercial use, so a business site should use a key from a plan that allows it. The add-on keeps its own counter and never sends more requests than you allow, and a held-back file follows the policy you chose for an unavailable scanner.

The Scanner settings of the Upload Virus Scan add-on: the scanner choice, the ClamAV address, the VirusTotal mode, the API key boxes and the Test connection result
The scanner settings with the API key boxes and the result of Test connection.
ClamAV Cloudmersive VirusTotal
Where the file goes Stays on your server Sent to the cloud Fingerprint only, or uploaded
Needs server software Yes No No
Works on shared hosting Rarely Yes Yes
Unknown new malware Depends on signatures Depends on signatures Fingerprint mode cannot judge new files
Speed Fastest with the daemon Network time Fingerprint is quick, upload is slower

Step by Step: Set It Up in Ten Minutes

  1. Install and activate the add-on and enter your license key under Forms, Settings, Upload Virus Scan.
  2. Open the Scanner section and choose a scanner. With ClamAV keep the address on auto.
  3. For Cloudmersive or VirusTotal paste your API key into its box and press Save key. The key is encrypted before it is stored and you only ever see its last four characters.
  4. Press Test connection. The add-on checks the scanner with the EICAR test file, a harmless text that every antivirus reports as a test virus. When it says the test file was detected, the scanner works.
  5. Set the time limit, the largest file and your message for the visitor, then save.
  6. Upload a file with the EICAR text to one of your forms to see the rejection, and a normal file to see it pass.

You never need real malware to test, and you should not use any. The EICAR text is built when the test runs and is deleted at once.

What if the Scanner Is Down?

Every scanner is unavailable sometimes: the daemon is restarting, the cloud service is slow, the rate limit is used up. You decide what a visitor should experience. The default is to allow the submission and flag the entry. The entry is saved, it carries a note and a status that say not scanned, and a line in the log tells you why, so nobody loses a job application because of a hiccup in a scanner. The other choice is to block the submission with a second message you write. Use it for forms where an unscanned file is worse than a lost submission.

Large Files Without Making Visitors Wait

Scanning a big file takes time and the visitor stares at a spinner. The later scan solves that. Turn it on, choose from which size a file is large, and the entry is saved at once with the status pending scan. A few seconds later WordPress scans the file in the background. If it is clean, the status changes. If it is infected, the file is deleted or moved to a protected quarantine folder, the entry gets a note, and you get an alert. A scanner that is busy or unreachable is tried again later, up to three times, and then the entry is marked not scanned.

There is a trade-off: for a few seconds the file exists in your uploads folder. For high-risk forms keep the scan at validation time and use the later scan only for large files.

See the Result on Every Entry

A Gravity Forms entry screen with the Notes box showing the note Virus scan: board-minutes.txt: Clean
A saved entry carries a note with the scan result of every file.

Each entry with a file gets a note with the scan result, and an entry value with the status. The merge tag for the status can be used in confirmations and notifications, which is handy to put in the e-mail that your team receives: they see at a glance whether the attachment was checked. Because a refused submission has no entry, the add-on adds a notification event called File infected. Create a notification for that event, send it to your security contact, and use the merge tag for the status in the subject.

Keep a Log, Keep No Content

The log on the settings page lists the last events with the time, the form, the file name, the signature, the scanner and the action. It is useful when someone asks why a file was refused. The add-on never stores file content. The verdict cache keeps only the SHA-256 for a few hours so that the same file is not scanned twice, and the log keeps names.

Privacy Questions to Settle First

  • Which files may leave your server? If the answer is none, use ClamAV.
  • If a cloud scanner is acceptable, which one fits your data processing rules? Read its terms and privacy information.
  • With VirusTotal, is fingerprint mode enough? Do not use upload mode for personal or confidential documents.
  • Is the free VirusTotal key allowed for your use? It is meant for non-commercial use.
  • Add the scanner to your privacy policy. The add-on adds a suggested text to the WordPress privacy policy guide.

Good Habits Around the Scan

  • Keep the list of allowed extensions short. Do not allow executables, scripts or archives unless you need them.
  • Keep your scanner up to date. A ClamAV daemon needs its signature updates to run.
  • A scan is one layer. Keep backups, keep WordPress and your plugins updated, and train your team not to open unexpected attachments.
  • Test after changes: upload the EICAR text again after you change the scanner, the key or the policy.

Frequently Asked Questions

Does it scan files that are already in my media library?

No. It scans files at the moment a Gravity Forms form with a File Upload field is submitted.

Will it slow down my forms?

A scan adds the time the scanner needs. A local ClamAV daemon is fast, cloud scanners take network time. You set a time limit, and large files can be scanned after the entry is saved.

Does it work with multi-file uploads and multi-page forms?

Yes. Files sent one by one with the multiple file uploader and files sent on an earlier page are checked, and an infected file is removed from the list.

What does the visitor see when a file is infected?

The message you wrote, on the File Upload field, and the form is shown again without the file.

Can I turn it off for one form?

Yes. Every form has a switch in its settings. It is on by default.

Checking uploads for malware is one of the few security steps that costs a few minutes to set up and removes a whole class of risk. Choose a scanner that fits your hosting and your privacy rules, test it with the EICAR text, decide what should happen when the scanner is down, and your upload forms stop being an open door.

See the Upload Virus Scan add-on

0
0
Your Cart
Your cart is emptyReturn to Shop
🔥 FREQUENTLY BOUGHT TOGETHER
Complete Combo & Save 40%!
ITEM IN YOUR CART
Gravity Forms Klaviyo Add-on
$39.00/yr
+
🎁 RECOMMENDED ADD-ON SAVE 40% OFF
Original Price: $39.00/yr
Bundle Special Price: $23.40/yr