--- url: "https://design-system.service.gov.uk/components/file-upload/" titulek: "File upload – GOV.UK Design System" h1: "File upload" popis: "Help users select and upload a file" jazyk: "en" kanonicka: "https://design-system.service.gov.uk/components/file-upload/" drobecky: ["Home", "Components"] zdroj: "live" wayback_snapshot: "" stazeno: "2026-09-14 01:21:40" znaku: 34336 slov: 5433 kodovani: "utf-8" sha256: "e8b8354d7e1acd71ff33eda01974d51714f2580f2b31061648f4de4e4bd61160" --- # File upload This guidance is for government teams that build online services. [To find information and services for the public, go to GOV.UK](https://www.gov.uk/). Help users select and upload a file. - HTML - Nunjucks HTML ```
``` Nunjucks Nunjucks macro options Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text. Some options are required for the macro to work; these are marked as “Required” in the option description. Deprecated options are marked as “Deprecated”. If you’re using Nunjucks macros in production with “html” options, or ones ending with “html”, you must sanitise the HTML to protect against [cross-site scripting exploits](https://developer.mozilla.org/en-US/docs/Glossary/Cross-site_scripting). Primary options string **Required.** The name of the input, which is submitted with the form data. string The ID of the input. Defaults to the value of `name`. If `javascript` is provided, this ID will be on the button of the improved version, and the hidden input’s ID will get the suffix “-input”. boolean If `true`, file input will be disabled. boolean If `true`, a user may select multiple files at the same time. The exact mechanism to do this differs depending on operating system. string One or more element IDs to add to the `aria-describedby` attribute, used to provide additional descriptive information for screenreader users. object **Required.** The label used by the file upload component. See macro options for label. object Can be used to add a hint to the file upload component. See macro options for hint. object Can be used to add an error message to the file upload component. The error message component will not display if you use a falsy value for `errorMessage`, for example `false` or `null`. [See macro options for errorMessage](/components/error-message/#options-error-message-example). object Additional options for the form group containing the file upload component. See macro options for formGroup. boolean Can be used to enable JavaScript enhancements for the component. string The text of the button that opens the file picker. Default is `"Choose file"`. If `javascript` is not provided, this option will be ignored. string The text informing users they can drop files. Default is `"or drop file"`. If `javascript` is not provided, this option will be ignored. object The text displayed when multiple files have been chosen by the user. The component will replace the `%{count}` placeholder with the number of files selected. [Our pluralisation rules apply to this macro option](https://frontend.design-system.service.gov.uk/localise-govuk-frontend/#understanding-pluralisation-rules). If `javascript` is not provided, this option will be ignored. string The text displayed when no file has been chosen by the user. Default is `"No file chosen"`. If `javascript` is not provided, this option will be ignored. string The text announced by assistive technology when user drags files and enters the drop zone. Default is `"Entered drop zone"`. If `javascript` is not provided, this option will be ignored. string The text announced by assistive technology when user drags files and leaves the drop zone without dropping. Default is `"Left drop zone"`. If `javascript` is not provided, this option will be ignored. string Classes to add to the file upload `` element. If `javascript` is provided, these are not copied to the visible button. To use classes for the visible button, use the `wrapperClasses` option. object HTML attributes (for example data attributes) to add to the file upload `` element. If `javascript` is provided, these are not copied to the visible button. To add attributes to the container, use the `wrapperAttributes` option instead. string Classes to add to the improved file upload component’s wrapper. If `javascript` is not provided, this option will be ignored. object HTML attributes (for example data attributes) to add to the improved file upload component’s wrapper. If `javascript` is not provided, this option will be ignored. Options for `formGroup` object string Classes to add to the form group (for example to show error state for the whole group). object HTML attributes (for example data attributes) to add to the form group. object Content to add before the input used by the file upload component. See macro options for formGroup beforeInput. object Content to add after the input used by the file upload component. See macro options for formGroup afterInput. Options for formGroup `beforeInput` object string **Required.** Text to add before the input. If `html` is provided, the `text` option will be ignored. string **Required.** HTML to add before the input. If `html` is provided, the `text` option will be ignored. Options for formGroup `afterInput` object string **Required.** Text to add after the input. If `html` is provided, the `text` option will be ignored. string **Required.** HTML to add after the input. If `html` is provided, the `text` option will be ignored. Options for `label` component string **Required.** If `html` is set, this is not required. Text to use within the label. If `html` is provided, the `text` option will be ignored. string **Required.** If `text` is set, this is not required. HTML to use within the label. If `html` is provided, the `text` option will be ignored. string The value of the `for` attribute, the ID of the input the label is associated with. boolean Whether the label also acts as the heading for the page. string Classes to add to the label tag. object HTML attributes (for example data attributes) to add to the label tag. Options for `hint` component string **Required.** If `html` is set, this is not required. Text to use within the hint. If `html` is provided, the `text` option will be ignored. string **Required.** If `text` is set, this is not required. HTML to use within the hint. If `html` is provided, the `text` option will be ignored. string Optional ID attribute to add to the hint span tag. string Classes to add to the hint span tag. object HTML attributes (for example data attributes) to add to the hint span tag. ``` {% from "govuk/components/file-upload/macro.njk" import govukFileUpload %} {{ govukFileUpload({ id: "file-upload-1", name: "fileUpload1", label: { text: "Upload a file" } }) }} ``` ## When to use this component You should only ask users to upload something if it’s critical to the delivery of your service. We improved the component in March 2025, so you’ll need to enable the improved File upload component as a new feature. Read a blog post about [design tips for helping users upload things](https://designnotes.blog.gov.uk/2017/02/14/some-design-tips-for-uploading-things/). ## How it works To upload a file, the user can either: - use the ‘Choose file’ button - drag and drop a file into the file upload input area ### Let users reuse uploaded files Make sure users can easily reuse a previously uploaded file within a single journey, unless doing so would be a major security or privacy concern. For example, a user might need to upload a photo of their driving licence to prove their identity, and again to prove their address. You can make it easier for the user to reuse a file by showing it as an option for the user to select so they do not need to upload it again. Consider users on public devices before choosing to make the file available to preview or download. There are 2 ways to use the file upload component. You can use HTML or, if you’re using [Nunjucks](https://mozilla.github.io/nunjucks/) or the [GOV.UK Prototype Kit](https://prototype-kit.service.gov.uk), you can use the Nunjucks macro. - HTML - Nunjucks HTML ```
``` Nunjucks Nunjucks macro options Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text. Some options are required for the macro to work; these are marked as “Required” in the option description. Deprecated options are marked as “Deprecated”. If you’re using Nunjucks macros in production with “html” options, or ones ending with “html”, you must sanitise the HTML to protect against [cross-site scripting exploits](https://developer.mozilla.org/en-US/docs/Glossary/Cross-site_scripting). Primary options string **Required.** The name of the input, which is submitted with the form data. string The ID of the input. Defaults to the value of `name`. If `javascript` is provided, this ID will be on the button of the improved version, and the hidden input’s ID will get the suffix “-input”. boolean If `true`, file input will be disabled. boolean If `true`, a user may select multiple files at the same time. The exact mechanism to do this differs depending on operating system. string One or more element IDs to add to the `aria-describedby` attribute, used to provide additional descriptive information for screenreader users. object **Required.** The label used by the file upload component. See macro options for label. object Can be used to add a hint to the file upload component. See macro options for hint. object Can be used to add an error message to the file upload component. The error message component will not display if you use a falsy value for `errorMessage`, for example `false` or `null`. [See macro options for errorMessage](/components/error-message/#options-error-message-example). object Additional options for the form group containing the file upload component. See macro options for formGroup. boolean Can be used to enable JavaScript enhancements for the component. string The text of the button that opens the file picker. Default is `"Choose file"`. If `javascript` is not provided, this option will be ignored. string The text informing users they can drop files. Default is `"or drop file"`. If `javascript` is not provided, this option will be ignored. object The text displayed when multiple files have been chosen by the user. The component will replace the `%{count}` placeholder with the number of files selected. [Our pluralisation rules apply to this macro option](https://frontend.design-system.service.gov.uk/localise-govuk-frontend/#understanding-pluralisation-rules). If `javascript` is not provided, this option will be ignored. string The text displayed when no file has been chosen by the user. Default is `"No file chosen"`. If `javascript` is not provided, this option will be ignored. string The text announced by assistive technology when user drags files and enters the drop zone. Default is `"Entered drop zone"`. If `javascript` is not provided, this option will be ignored. string The text announced by assistive technology when user drags files and leaves the drop zone without dropping. Default is `"Left drop zone"`. If `javascript` is not provided, this option will be ignored. string Classes to add to the file upload `` element. If `javascript` is provided, these are not copied to the visible button. To use classes for the visible button, use the `wrapperClasses` option. object HTML attributes (for example data attributes) to add to the file upload `` element. If `javascript` is provided, these are not copied to the visible button. To add attributes to the container, use the `wrapperAttributes` option instead. string Classes to add to the improved file upload component’s wrapper. If `javascript` is not provided, this option will be ignored. object HTML attributes (for example data attributes) to add to the improved file upload component’s wrapper. If `javascript` is not provided, this option will be ignored. Options for `formGroup` object string Classes to add to the form group (for example to show error state for the whole group). object HTML attributes (for example data attributes) to add to the form group. object Content to add before the input used by the file upload component. See macro options for formGroup beforeInput. object Content to add after the input used by the file upload component. See macro options for formGroup afterInput. Options for formGroup `beforeInput` object string **Required.** Text to add before the input. If `html` is provided, the `text` option will be ignored. string **Required.** HTML to add before the input. If `html` is provided, the `text` option will be ignored. Options for formGroup `afterInput` object string **Required.** Text to add after the input. If `html` is provided, the `text` option will be ignored. string **Required.** HTML to add after the input. If `html` is provided, the `text` option will be ignored. Options for `label` component string **Required.** If `html` is set, this is not required. Text to use within the label. If `html` is provided, the `text` option will be ignored. string **Required.** If `text` is set, this is not required. HTML to use within the label. If `html` is provided, the `text` option will be ignored. string The value of the `for` attribute, the ID of the input the label is associated with. boolean Whether the label also acts as the heading for the page. string Classes to add to the label tag. object HTML attributes (for example data attributes) to add to the label tag. Options for `hint` component string **Required.** If `html` is set, this is not required. Text to use within the hint. If `html` is provided, the `text` option will be ignored. string **Required.** If `text` is set, this is not required. HTML to use within the hint. If `html` is provided, the `text` option will be ignored. string Optional ID attribute to add to the hint span tag. string Classes to add to the hint span tag. object HTML attributes (for example data attributes) to add to the hint span tag. ``` {% from "govuk/components/file-upload/macro.njk" import govukFileUpload %} {{ govukFileUpload({ id: "file-upload-1", name: "fileUpload1", label: { text: "Upload a file" } }) }} ``` ### Error messages Error messages should be styled like this: - HTML - Nunjucks HTML ```

Error: The CSV must be smaller than 2MB

``` Nunjucks Nunjucks macro options Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text. Some options are required for the macro to work; these are marked as “Required” in the option description. Deprecated options are marked as “Deprecated”. If you’re using Nunjucks macros in production with “html” options, or ones ending with “html”, you must sanitise the HTML to protect against [cross-site scripting exploits](https://developer.mozilla.org/en-US/docs/Glossary/Cross-site_scripting). Primary options string **Required.** The name of the input, which is submitted with the form data. string The ID of the input. Defaults to the value of `name`. If `javascript` is provided, this ID will be on the button of the improved version, and the hidden input’s ID will get the suffix “-input”. boolean If `true`, file input will be disabled. boolean If `true`, a user may select multiple files at the same time. The exact mechanism to do this differs depending on operating system. string One or more element IDs to add to the `aria-describedby` attribute, used to provide additional descriptive information for screenreader users. object **Required.** The label used by the file upload component. See macro options for label. object Can be used to add a hint to the file upload component. See macro options for hint. object Can be used to add an error message to the file upload component. The error message component will not display if you use a falsy value for `errorMessage`, for example `false` or `null`. [See macro options for errorMessage](/components/error-message/#options-error-message-example). object Additional options for the form group containing the file upload component. See macro options for formGroup. boolean Can be used to enable JavaScript enhancements for the component. string The text of the button that opens the file picker. Default is `"Choose file"`. If `javascript` is not provided, this option will be ignored. string The text informing users they can drop files. Default is `"or drop file"`. If `javascript` is not provided, this option will be ignored. object The text displayed when multiple files have been chosen by the user. The component will replace the `%{count}` placeholder with the number of files selected. [Our pluralisation rules apply to this macro option](https://frontend.design-system.service.gov.uk/localise-govuk-frontend/#understanding-pluralisation-rules). If `javascript` is not provided, this option will be ignored. string The text displayed when no file has been chosen by the user. Default is `"No file chosen"`. If `javascript` is not provided, this option will be ignored. string The text announced by assistive technology when user drags files and enters the drop zone. Default is `"Entered drop zone"`. If `javascript` is not provided, this option will be ignored. string The text announced by assistive technology when user drags files and leaves the drop zone without dropping. Default is `"Left drop zone"`. If `javascript` is not provided, this option will be ignored. string Classes to add to the file upload `` element. If `javascript` is provided, these are not copied to the visible button. To use classes for the visible button, use the `wrapperClasses` option. object HTML attributes (for example data attributes) to add to the file upload `` element. If `javascript` is provided, these are not copied to the visible button. To add attributes to the container, use the `wrapperAttributes` option instead. string Classes to add to the improved file upload component’s wrapper. If `javascript` is not provided, this option will be ignored. object HTML attributes (for example data attributes) to add to the improved file upload component’s wrapper. If `javascript` is not provided, this option will be ignored. Options for `formGroup` object string Classes to add to the form group (for example to show error state for the whole group). object HTML attributes (for example data attributes) to add to the form group. object Content to add before the input used by the file upload component. See macro options for formGroup beforeInput. object Content to add after the input used by the file upload component. See macro options for formGroup afterInput. Options for formGroup `beforeInput` object string **Required.** Text to add before the input. If `html` is provided, the `text` option will be ignored. string **Required.** HTML to add before the input. If `html` is provided, the `text` option will be ignored. Options for formGroup `afterInput` object string **Required.** Text to add after the input. If `html` is provided, the `text` option will be ignored. string **Required.** HTML to add after the input. If `html` is provided, the `text` option will be ignored. Options for `label` component string **Required.** If `html` is set, this is not required. Text to use within the label. If `html` is provided, the `text` option will be ignored. string **Required.** If `text` is set, this is not required. HTML to use within the label. If `html` is provided, the `text` option will be ignored. string The value of the `for` attribute, the ID of the input the label is associated with. boolean Whether the label also acts as the heading for the page. string Classes to add to the label tag. object HTML attributes (for example data attributes) to add to the label tag. Options for `hint` component string **Required.** If `html` is set, this is not required. Text to use within the hint. If `html` is provided, the `text` option will be ignored. string **Required.** If `text` is set, this is not required. HTML to use within the hint. If `html` is provided, the `text` option will be ignored. string Optional ID attribute to add to the hint span tag. string Classes to add to the hint span tag. object HTML attributes (for example data attributes) to add to the hint span tag. ``` {% from "govuk/components/file-upload/macro.njk" import govukFileUpload %} {{ govukFileUpload({ id: "file-upload-1", name: "fileUpload1", label: { text: "Upload a file" }, errorMessage: { text: "The CSV must be smaller than 2MB" } }) }} ``` Make sure errors follow the guidance in the [Error message component](/components/error-message/) and have specific error messages for specific error states. #### If no file has been selected Say ‘Select a [whatever they need to select]’. For example, ‘Select a report’. #### If the file is the wrong file type Say ‘The selected file must be a [list of file types]’. For example, ‘The selected file must be a CSV or ODS’ or ‘The selected file must be a JPG, BMP, PNG, TIF or PDF’. #### If the file is too big Say ‘The selected file must be smaller than [largest file size]’. For example, ‘The selected file must be smaller than 2MB’. #### If the file is empty Say ‘The selected file is empty’. #### If the file contains a virus Say ‘The selected file contains a virus’. #### If the file is password protected Say ‘The selected file is password protected’. #### If there was a problem and the file was not uploaded Say ‘The selected file could not be uploaded – try again’. #### If there is a limit on how many files the user can select Say ‘You can only select up to [highest number] files at the same time’. For example, ‘You can only select up to 10 files at the same time’. #### If the file is not in a template that must be used or the template has been changed Say ‘The selected file must use the template’. ## Using the improved File upload component In March 2025, we introduced changes to the File upload component that service teams can opt in to as part of GOV.UK Frontend 5.9.0. The improved component is intended to: - fix accessibility issues - improve the user experience - allow text in the component to be translated We recommend service teams start using the latest component to improve the experience for users. However, it’s a visual change from the previous component and might affect existing designs and layouts. To let teams migrate at their own pace, the improvements are only enabled if you use the `javascript` macro option or extra markup in your HTML. This example shows you how to enable the improved File upload component: - HTML - Nunjucks HTML ```
``` Nunjucks Nunjucks macro options Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text. Some options are required for the macro to work; these are marked as “Required” in the option description. Deprecated options are marked as “Deprecated”. If you’re using Nunjucks macros in production with “html” options, or ones ending with “html”, you must sanitise the HTML to protect against [cross-site scripting exploits](https://developer.mozilla.org/en-US/docs/Glossary/Cross-site_scripting). Primary options string **Required.** The name of the input, which is submitted with the form data. string The ID of the input. Defaults to the value of `name`. If `javascript` is provided, this ID will be on the button of the improved version, and the hidden input’s ID will get the suffix “-input”. boolean If `true`, file input will be disabled. boolean If `true`, a user may select multiple files at the same time. The exact mechanism to do this differs depending on operating system. string One or more element IDs to add to the `aria-describedby` attribute, used to provide additional descriptive information for screenreader users. object **Required.** The label used by the file upload component. See macro options for label. object Can be used to add a hint to the file upload component. See macro options for hint. object Can be used to add an error message to the file upload component. The error message component will not display if you use a falsy value for `errorMessage`, for example `false` or `null`. [See macro options for errorMessage](/components/error-message/#options-error-message-example). object Additional options for the form group containing the file upload component. See macro options for formGroup. boolean Can be used to enable JavaScript enhancements for the component. string The text of the button that opens the file picker. Default is `"Choose file"`. If `javascript` is not provided, this option will be ignored. string The text informing users they can drop files. Default is `"or drop file"`. If `javascript` is not provided, this option will be ignored. object The text displayed when multiple files have been chosen by the user. The component will replace the `%{count}` placeholder with the number of files selected. [Our pluralisation rules apply to this macro option](https://frontend.design-system.service.gov.uk/localise-govuk-frontend/#understanding-pluralisation-rules). If `javascript` is not provided, this option will be ignored. string The text displayed when no file has been chosen by the user. Default is `"No file chosen"`. If `javascript` is not provided, this option will be ignored. string The text announced by assistive technology when user drags files and enters the drop zone. Default is `"Entered drop zone"`. If `javascript` is not provided, this option will be ignored. string The text announced by assistive technology when user drags files and leaves the drop zone without dropping. Default is `"Left drop zone"`. If `javascript` is not provided, this option will be ignored. string Classes to add to the file upload `` element. If `javascript` is provided, these are not copied to the visible button. To use classes for the visible button, use the `wrapperClasses` option. object HTML attributes (for example data attributes) to add to the file upload `` element. If `javascript` is provided, these are not copied to the visible button. To add attributes to the container, use the `wrapperAttributes` option instead. string Classes to add to the improved file upload component’s wrapper. If `javascript` is not provided, this option will be ignored. object HTML attributes (for example data attributes) to add to the improved file upload component’s wrapper. If `javascript` is not provided, this option will be ignored. Options for `formGroup` object string Classes to add to the form group (for example to show error state for the whole group). object HTML attributes (for example data attributes) to add to the form group. object Content to add before the input used by the file upload component. See macro options for formGroup beforeInput. object Content to add after the input used by the file upload component. See macro options for formGroup afterInput. Options for formGroup `beforeInput` object string **Required.** Text to add before the input. If `html` is provided, the `text` option will be ignored. string **Required.** HTML to add before the input. If `html` is provided, the `text` option will be ignored. Options for formGroup `afterInput` object string **Required.** Text to add after the input. If `html` is provided, the `text` option will be ignored. string **Required.** HTML to add after the input. If `html` is provided, the `text` option will be ignored. Options for `label` component string **Required.** If `html` is set, this is not required. Text to use within the label. If `html` is provided, the `text` option will be ignored. string **Required.** If `text` is set, this is not required. HTML to use within the label. If `html` is provided, the `text` option will be ignored. string The value of the `for` attribute, the ID of the input the label is associated with. boolean Whether the label also acts as the heading for the page. string Classes to add to the label tag. object HTML attributes (for example data attributes) to add to the label tag. Options for `hint` component string **Required.** If `html` is set, this is not required. Text to use within the hint. If `html` is provided, the `text` option will be ignored. string **Required.** If `text` is set, this is not required. HTML to use within the hint. If `html` is provided, the `text` option will be ignored. string Optional ID attribute to add to the hint span tag. string Classes to add to the hint span tag. object HTML attributes (for example data attributes) to add to the hint span tag. ``` {% from "govuk/components/file-upload/macro.njk" import govukFileUpload %} {{ govukFileUpload({ id: "file-upload-1", name: "fileUpload1", label: { text: "Upload a file" }, javascript: true }) }} ``` ### About HTML attributes JavaScript creates the improved version of the component out of the input (``) and then hides the input from the user. The improved version consists of a `