Components

customfileupload

Standard citizen document upload. The file is encoded as base64 and sent inline as part of the application payload on submission.

Standard citizen document upload. The file is encoded as base64 and sent inline as part of the application payload on submission.

Read Form Rules before using this component — keys, labels, required fields, expressions, visibility, and validation all follow shared conventions.

When to use

  • Uploading attachments that must travel with the form data (ID scans, certificates, supporting documents)
  • The file does not need to be pre-uploaded to a CDN before submission
  • No external integration endpoint is involved in the upload

When NOT to use

Instead of customfileupload, use…For…
custominternalfileuploadLarge or sensitive documents that should be pre-uploaded to the CDN — sending them as base64 inline bloats the application payload
externalfileuploadFiles that must be pushed directly to an external system via an integration endpoint at upload time

Props

PropTypeRequired?Description
labelstringrequiredVisible label. Must be unique across the form.
requiredbooleanrequiredAlways false. The expression controls the runtime value.
defaultRequiredbooleanrequiredtrue for required fields, false for optional ones.
allowedFormatsarrayrequiredAccepted file extensions in lowercase (e.g. ["pdf", "jpg", "jpeg", "png"]). Do not include uppercase variants — the check is case-insensitive.
maximumUploadSizenumberrequiredMaximum file size in KB (e.g. 1024 = 1 MB, 500 = 500 KB).
minimumUploadSizenumberoptionalMinimum file size in KB. Use 1 to prevent empty files.
placeholderstringoptionalText shown on the upload button.
hintstringoptionalHelp text below the field — use for format/size guidance.
hideFieldbooleanoptionalHides the field and excludes its value. Toggle via expressions["props.hideField"].

Validation messages

KeyWhen requiredNotes
requiredAlways
invalidfileformatAlwaysState the field name and accepted formats.
maximumUploadSizeAlwaysState the field name and size limit.
minimumUploadSizeWhen minimumUploadSize is set

Examples

PDF only

{
  "key": "DEATH_CERTIFICATE",
  "type": "customfileupload",
  "props": {
    "label": "Death Certificate",
    "placeholder": "Select file to upload",
    "required": false,
    "defaultRequired": true,
    "allowedFormats": ["pdf"],
    "maximumUploadSize": 1024
  },
  "expressions": {
    "props.required": "!(field?.props?.hideField || field?.hide) && field?.props?.defaultRequired"
  },
  "validation": {
    "messages": {
      "required": "This field is required.",
      "invalidfileformat": "Only PDF files are allowed.",
      "maximumUploadSize": "File must be smaller than 1 MB."
    }
  }
}

Multiple image formats with hint

{
  "key": "APPLICANT_PHOTO",
  "type": "customfileupload",
  "props": {
    "label": "Applicant Photo",
    "placeholder": "Select file to upload",
    "required": false,
    "defaultRequired": true,
    "allowedFormats": ["jpg", "jpeg", "png"],
    "maximumUploadSize": 2048,
    "minimumUploadSize": 1,
    "hint": "Upload a recent passport-size photo. JPG or PNG, max 2 MB."
  },
  "expressions": {
    "props.required": "!(field?.props?.hideField || field?.hide) && field?.props?.defaultRequired"
  },
  "validation": {
    "messages": {
      "required": "This field is required.",
      "invalidfileformat": "Only JPG and PNG files are allowed.",
      "maximumUploadSize": "Photo must be 2 MB or smaller.",
      "minimumUploadSize": "File size must be at least 1 KB."
    }
  }
}

Common mistakes

  • Setting maximumUploadSize in bytes or MB — the prop is always in KB.
  • Including uppercase variants in allowedFormats (e.g. ["pdf", "PDF"]) — redundant; use lowercase only.
  • Omitting allowedFormats — the component accepts any file type; always restrict explicitly.
  • Using customfileupload for large documents — use custominternalfileupload (CDN pre-upload) to avoid bloating the payload.
  • Using customfileupload when the file must be pushed to an external endpoint — use externalfileupload instead.

Checklist

  • key is UPPER_SNAKE_CASE and unique across the entire form
  • props.label is present, unique, and correctly cased
  • Field is nested at the correct depth: sections > formly-group > block > customfileupload
  • required: false is set (never true)
  • defaultRequired is set
  • expressions["props.required"] is present with the exact required expression
  • allowedFormats is lowercase only
  • maximumUploadSize is in KB
  • validation.messages has required, invalidfileformat, and maximumUploadSize
  • Confirmed the file should travel as base64 inline — if not, use custominternalfileupload

On this page