A form on your own site can send attachments with a normal form post. Without anything extra, a direct post accepts up to 25 MiB per file and 125 MiB per submission. Above that, Formward needs proof that a person is behind the request before it accepts a long upload, so the browser first trades a captcha token for an upload ticket and then sends the form with that ticket.
Formward's own form pages and Formbutton do this for you. This guide shows how to do it on your own page, with plain HTML and about 30 lines of JavaScript.
What you get
With a ticket, the plan limits apply in full:
- Professional: 5 files per submission, 250 MiB per file, 500 MiB per submission.
- Business: 10 files per submission, 500 MiB per file, 1024 MiB per submission.
Uploads need the Professional or Business plan and uploads switched on for the form. See file uploads for accepted file types.
1. Switch on captcha for the form
In the dashboard, open the form, go to Settings and switch on Formward's captcha. You can use Turnstile instead; see spam protection.
Copy the widget snippet from the same settings page into your form. It looks like this:
<form id="upload-form" action="https://forms.formward.eu/f/YOUR_FORM_ID" method="POST" enctype="multipart/form-data">
<input name="name" required>
<input type="file" name="photos" multiple>
<script src="https://forms.formward.eu/cap/widget.js" async></script>
<cap-widget required data-cap-api-endpoint="https://forms.formward.eu/cap/YOUR_FORM_ID/"></cap-widget>
<button type="submit">Send</button>
</form>The widget adds a hidden cap-token field to the form once it has solved its check. With Turnstile, the field is cf-turnstile-response.
2. Trade the token for a ticket, then send the form
Add this script after the form. It exchanges the captcha token for a ticket, takes the token out of the form, and submits the form with the ticket in the Authorization header.
const form = document.getElementById("upload-form");
form.addEventListener("submit", async (event) => {
event.preventDefault();
const data = new FormData(form);
const tokens = {};
for (const name of ["cap-token", "cf-turnstile-response"]) {
if (data.get(name)) tokens[name] = data.get(name);
}
if (!Object.keys(tokens).length) return alert("Please wait for the captcha check to finish.");
const headers = { Accept: "application/json" };
const exchange = await fetch(form.action + "/upload-ticket", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(tokens),
});
if (!exchange.ok) return showError(await exchange.json().catch(() => ({})));
const { ticket } = await exchange.json();
for (const name of Object.keys(tokens)) data.delete(name);
headers.Authorization = "FormwardUpload " + ticket;
const response = await fetch(form.action, { method: "POST", headers, body: data });
const result = await response.json().catch(() => ({}));
if (!response.ok) return showError(result);
form.reset();
alert("Thank you, we received your submission.");
});
function showError(body) {
const ref = body.ref ? " (reference " + body.ref + ")" : "";
alert((body.error || "Something went wrong, please try again") + ref);
}Replace the two alert calls with your own messages. Because the form is sent with fetch, the browser stays on your page; a _redirect field is not followed.
How the ticket works
POST https://forms.formward.eu/f/YOUR_FORM_ID/upload-tickettakes a JSON body with the captcha field (cap-tokenorcf-turnstile-response) and answers{ "ticket": "..." }. A missing or invalid token gets403with"captcha failed".- The ticket belongs to that one form, works once, and is valid for 75 minutes. The upload has to start within that time.
- The captcha token is used up by the exchange, so the submission itself carries only the ticket.
- Your site must be allowed to post to the form. If you limited the form to certain domains, your page's domain has to be on that list.
When something is refused
A refused submission answers with a JSON body such as { "ok": false, "error": "upload too large", "ref": "E-ABC123" }. The script above shows the message and the reference. Send the reference to support and we can see why that submission was refused.
Common answers:
- 413: a file or the whole submission is over the plan limit, or over 25 MiB per file or 125 MiB per submission without a ticket.
- 415: the file type is not accepted.
- 403: the captcha token or the ticket was missing, used or expired. Let the widget run again and resubmit.
- 503 with Retry-After: Formward is handling many large uploads right now. Wait the given number of seconds and try again.
Without JavaScript
If you cannot add a script, the form still works as a plain HTML post with the captcha widget, up to 25 MiB per file and 125 MiB per submission. Without a ticket the upload has to finish within 15 minutes, or within 3 minutes when the form uses Turnstile. For larger files without your own code, use a Formward form page or Formbutton.