File uploads

Let form submitters attach files with multipart/form-data posts, see how uploads are priced, and download the files afterwards.

Turn on files and a form takes multipart/form-data posts with files:

await ..({
  : "Job application",
  : [
    { : "email", : "email", : true },
    { : "cv", : "file", : "CV", : true },
  ],
  : { : true, : 2, : ["application/pdf", "image/*"] },
});
<form action="https://…/f/form_01k…" method="post" enctype="multipart/form-data">
  <input type="email" name="email" required>
  <input type="file" name="cv" accept="application/pdf,image/*" required>
  <button>Apply</button>
</form>

HTML, SVG, scripts and executables are always refused, whatever allowed_types says, and so are files whose names end in their extensions. Filenames keep only their last part. With fields defined, files are accepted only in file fields; a form without uploads refuses posts that carry files.

Files are kept with their submission (deleted with it, and like it after 90 days). Spam caught by the honeypot keeps none.

Pricing

An accepted live submission's files are billed with it, $0.25 per 1,000 MB, which covers keeping them: each submission's files are added up and rounded up to the next MB (1 MB = 1,048,576 bytes). Spam, held and unconfirmed submissions' files cost nothing unless you release them or the submitter confirms, and sandbox forms bill nothing. The Free plan includes 1,000 MB of form uploads a month; past it, a post with files is refused with an error on the file field (the submitter can send the form without them) until the month resets or you upgrade.

Downloading

Webhooks and the API list a submission's files (files[]: id, field, filename, type, size); fetch one's bytes with:

const { :  } = await ...(, , );
// bytes: Uint8Array

The API serves them as application/octet-stream and the dashboard as downloads: a submitter chose these files, so never open them in your app's own origin. coss.com doesn't scan them for malware.

Last updated