Skip to content
Formward
Log inStart free
← Back to blog

The Formward journal

Test a Form File Upload With a Synthetic File

Prove a form upload carries the file's bytes, not just its name: a local Node check, the browser request, and where the file shows up in Formward.

A filename in a notification email does not prove the file arrived. To test a form file upload properly, send a file whose contents you know, then open it at the other end and check those contents. This post does that in three steps: a local check with no network, the browser's real request, and the place the file lands.

The test file contains one marker, UPLOAD-CHECK-01. Nothing personal, nothing you would mind seeing in a log.

Run a local baseline with no endpoint

This Node script builds a multipart body in memory and parses it again. It reads nothing from disk and sends nothing anywhere. It answers one question: does a multipart request carry the file's bytes, name and size intact? You need a Node release with the built-in FormData and Request globals. Save it as upload-check.mjs and run node upload-check.mjs.

const marker = "UPLOAD-CHECK-01";
const body = new FormData();
body.append(
  "attachment",
  new Blob([marker], { type: "text/plain" }),
  "upload-check.txt"
);
const request = new Request("https://example.invalid/upload", {
  method: "POST",
  body
});
if (!request.headers.get("content-type").includes("boundary=")) {
  throw new Error("Missing multipart boundary");
}
const parsed = await request.formData();
const file = parsed.get("attachment");
if (
  !file || typeof file === "string" ||
  file.name !== "upload-check.txt" ||
  file.size !== 15 ||
  await file.text() !== marker
) {
  throw new Error("File contents or metadata did not survive");
}
console.log("PASS: filename, 15-byte size and marker preserved");

Creating a Request does not send it, and Request.formData() parses the body locally. A pass means the encoding works. It says nothing yet about your form, the endpoint or the plan limits. If it fails, look at your Node version or the copied code before you touch a live form.

Compare with the browser's real request

For the form, make a fixture in a format the field accepts. If the input only takes PDFs, make a real PDF with the marker in it and note its exact size. A text file renamed to .pdf is not a PDF.

Open the page, turn on Preserve log in the Network tab, attach the file and send. Then look at the request. Three things go wrong most often:

  • The file shows up as a plain text value with only its name. The form is missing enctype="multipart/form-data", or method="post". The multipart guide shows what a correct file part looks like.
  • The file field is missing entirely. The input has no name, is disabled, or sits outside the form. Or a script builds the payload by hand and copies only the text fields.
  • A FormData body that fails to parse. Some code sets Content-Type by hand. Remove it and let the browser write the header with the boundary. MDN covers this in Using FormData Objects. A JSON body cannot carry a file at all, whatever the header says.

The HTML form tester catches the first two from the markup alone. It does not read your file or contact the endpoint.

Where the file shows up in Formward

Uploads work on Professional and Business, and only when uploads are switched on for that form. A post with a file to a form without them gets a 403 that says which one is missing. The limits per submission:

  • Professional: up to 5 files, 10 MiB each, 25 MiB in total, with 2 GiB of stored attachments per organization.
  • Business: up to 10 files, 25 MiB each, 25 MiB in total, with 10 GiB stored.

A file over the limit gets a 413 with the limit in the error text. Read it before you start changing the encoding.

Once the submission is accepted, there are three places to look, and they show different things:

  • The dashboard. The submission page lists each file, and that is where you download it. Download the fixture and check the marker and the size. This is the only check that proves the bytes arrived.
  • The notification email. It lists each file's name and size with a link to the submission in the dashboard. The file itself is not attached to the email. In link-only mode, or on a form with a sensitive-field list, the file names are left out too.
  • Webhooks. The webhook payload carries the submission's text fields. It does not include the file or a link to it, so a receiver that needs the file has to get it some other way.

So if the email shows the name and the webhook shows nothing, that is expected. A missing file in the dashboard is not. More on setup and limits in the file upload docs.

Clean up

Write down the page, fixture name, marker, expected size, whether it was a native form or a fetch handler, and what you found in the dashboard. A native-form pass does not cover a fetch handler, or the other way round.

Then delete the test submission, which removes its files with it. The launch checklist covers the remaining checks for the form.

About the author

The Formward Team builds privacy-first form infrastructure in Stockholm. Read about our security and privacy practices. Our approach follows the principles set out by the European Data Protection Board at edpb.europa.eu.