File Button
File Button is a button component that opens the file picker dialog when clicked, allowing users to select and upload files. Once files are selected, the button label updates to show the selected file count, and the file data is made available through exposed variables for use in queries and other components.
Example Usage​
A logistics company builds an internal tool for processing bulk shipment orders. Employees click the File Button to upload a CSV file containing hundreds of order entries. The parsed CSV data is then bound to a table query that inserts each row into the database — eliminating manual data entry entirely.
Properties​
| Property | Description | Expected Value |
|---|---|---|
| Button text | The label shown on the button before any file is selected. Updates to show file count after selection. | String (e.g., Upload file). Default: Upload file. |
| Enable multiple files | Allows users to select more than one file at a time. | Toggle on/off or use fx to set {{true}} or {{false}}. Default: false. |
| Parse file content | When enabled, ToolJet automatically reads and parses the content of selected files into structured data. | Toggle on/off or use fx to set {{true}} or {{false}}. Default: false. |
| File type | Specifies the format ToolJet uses to parse the file content. Only shown when Parse file content is enabled. | Select one of: Autodetect from extension, CSV, XLS, XLSX, JSON. Default: Autodetect from extension. |
| Delimiter | The character used to separate values when parsing CSV files. Only shown when Parse file content is enabled and File type is CSV. | String (e.g., , or ;). Default: ,. |
Events​
| Event | Description |
|---|---|
| On file selected | Fires immediately when the user picks a file from the dialog, before content is read. |
| On file loaded | Fires after the file has been fully read and processed by ToolJet. |
Component Specific Actions (CSA)​
Following actions of File Button component can be controlled using the component specific actions(CSA):
Action | Description | How To Access |
|---|---|---|
| clear() | Clears all selected files and resets the button label. | Use a RunJS query: await components.filebutton1.clear() or trigger it using an event. |
| setFocus() | Brings focus to the file button. | Use a RunJS query: await components.filebutton1.setFocus() or trigger it using an event. |
| setBlur() | Removes focus from the file button. | Use a RunJS query: await components.filebutton1.setBlur() or trigger it using an event. |
| setVisibility() | Shows or hides the component. | Use a RunJS query: await components.filebutton1.setVisibility(true) or trigger it using an event. |
| setDisable() | Enables or disables the component. | Use a RunJS query: await components.filebutton1.setDisable(true) or trigger it using an event. |
| setLoading() | Toggles the loading spinner on the button. | Use a RunJS query: await components.filebutton1.setLoading(true) or trigger it using an event. |
Exposed Variables​
| Variable | Description | How To Access |
|---|---|---|
| files | Array of processed file objects. Each object contains name, size, type, content (raw text), base64Data, parsedValue (structured parsed data), and lastModified. | {{components.filebutton1.files}} |
| fileSize | Total size in bytes of all currently selected files. | {{components.filebutton1.fileSize}} |
| isParsing | true while ToolJet is actively reading and parsing file content. | {{components.filebutton1.isParsing}} |
| isValid | true when the component's validation rules are satisfied (mandatory check and min file count). | {{components.filebutton1.isValid}} |
| isMandatory | true when the Make this field mandatory validation option is enabled. | {{components.filebutton1.isMandatory}} |
| isLoading | true when the component is in loading state. | {{components.filebutton1.isLoading}} |
| isVisible | true when the component is visible. | {{components.filebutton1.isVisible}} |
| isDisabled | true when the component is disabled. | {{components.filebutton1.isDisabled}} |
Validation​
Validation Option | Description | Expected Value |
|---|---|---|
| Make this field mandatory | Marks the file selection as required. Shows an error message if the user submits without selecting a file. | Toggle on/off or use fx. Default: false. |
| File type | Restricts which file types the picker will accept. Supports MIME types and extensions. | String (e.g., image/*, .pdf, image/png,.pdf). Default: */* (all types). |
| Min size (bytes) | The minimum allowed size for each file. Files smaller than this are rejected. | Number (e.g., 1024 for 1 KB). Default: 0. |
| Max size (bytes) | The maximum allowed size for each file. Files larger than this are rejected. | Number (e.g., 1048576 for 1 MB). Default: 1048576. |
| Min file count | The minimum number of files that must be selected. Only shown when Enable multiple files is on. | Number (e.g., 1). Default: 1. |
| Max file count | The maximum number of files that can be selected. Only shown when Enable multiple files is on. | Number (e.g., 5). Default: 2. |