Skip to main content

The File Input component for Retool Mobile

Properties​

All properties for this object with supported data types or values. You can write JavaScript almost anywhere in Retool to manipulate or read property values.

accept​

A list of file extensions or file-type specifiers to accept.

Type array
Array values string
Configurability Inspector > content > File types
Defaultnull
Examples
false["image/*", "pdf", "doc"]

customValidation​

A custom validation rule using {{ }} expression with conditional logic. An invalid match evaluates to a string which is used as the validation message. An empty or nullish value is considered valid.

Type string
Format Plain Text
Configurability Inspector > Interaction > Validation rules > Custom rule
Defaultnull
Examples
false"{{ value.length > 5 ? 'Value must be longer than 5 characters' : '' }}"

disabled​

Whether input, interaction, selection, or triggering is disabled.

Type boolean
Format True/False
Configurability Inspector > Interaction > Disabled
Defaultfalse
Examples
falsetrue

events​

A list of configured event handlers that trigger actions or queries.

Type array
Array values object
Configurability Inspector > Interaction > Event handlers
Defaultnull
Array Object Properties

event​

The event that triggers the action. Refer to the events section for details of available events for this object.

Type string
Configurability Inspector > Interaction > Event handlers > Event
Defaultnull

method​

The JavaScript method to perform when type is datasource, widget, state, or localStorage.

Type string
Configurability Inspector > Interaction > Event handlers > Edit event handler > Run script actions
Defaultnull

type​

The type of action to perform.

Type string
Configurability Inspector > Interaction > Event handlers > Edit event handler > Action
Allowed Values
ValueDescription
datasource

Control query.

widget

Control component.

script

Run script.

state

Set variable.

localStorage

Set localStorage.

util

Perform utility action (e.g., Open URL or Confetti).

Defaultnull


file​

Details about the selected file.

Type object
Configurability Read-only
Defaultnull
Object Properties

lastModified​

The last modified date as a timestamp.

Type number
Format Timestamp
Configurability Read-only
Defaultnull
Examples
false1617024000000

name​

The file name with extension.

Type string
Configurability Read-only
Defaultnull

retoolStorageId​

The file ID if uploaded to Retool Storage.

Type string
Configurability Read-only
Defaultnull

size​

The file size, in bytes.

Type string
Configurability Read-only
Defaultnull

type​

The MIME type.

Type string
Configurability Read-only
Defaultnull

uploading​

Whether the file is uploading.

Type boolean
Configurability Read-only
Defaultnull


formDataKey​

The key used by a Form component to assign default values to input fields using form.initialData, and to construct the form.data property.

Type string
Format Plain Text
Configurability Inspector > Interaction > Form data key
Default{{ self.id }}
Examples
falsetable1.selectedRow.id

hidden​

Whether this object is hidden from view.

Type boolean
Format True/False
Configurability Inspector > Appearance > Hidden
Defaultfalse
Examples
falsetrue

hideValidationMessage​

Whether to hide the validation message if the invalid is true.

Type boolean
Configurability Inspector > Appearance > Advanced > Hide validation message
Defaultnull

invalid​

Whether the value has failed any validation rules.

Type boolean
Configurability Read-only
Defaultnull

isPublic​

Whether to make the file public when uploading with Retool Storage.

Type boolean
Configurability Inspector
Defaultnull

Examples
false"Label"

placeholder​

The text to display within the input field when there is no value.

Type string
Formatstring
Configurability Inspector > Content > Placeholder
DefaultEnter a value
Examples
falseEnter a value

Examples
falsetrue

shouldOverwriteOnNameCollision​

Whether to replace a file with the same name when uploading with Retool Storage.

Type boolean
Configurability Inspector
Defaultnull

uploadToRetoolStorage​

Whether to upload a file to Retool Storage.

Type boolean
Configurability Inspector
Defaultnull

validationMessage​

The validation message to display if invalid is true.

Type string
Format Plain Text
Configurability Read-only
Defaultnull

value​

The value.

Type string
Format Blob or file URI
Configurability Read-only
Defaultnull
Examples
falseblob:example.com/12345678-1234-5678-1234-567812345678
falsefile://path/to/file

Methods​

JavaScript API methods for this object. You can write JavaScript almost anywhere in Retool and use methods to manipulate data and property values.

fileInput.clearValidation()​

Clear the validation message from the input field.

Definition
fileInput.clearValidation()
Examples

Clear the validation message from fileInput.

fileInput.clearValidation();

fileInput.clearValue()​

Clear the current values.

Definition
fileInput.clearValue()
Examples

Clear the current value of fileInput.

fileInput.clearValue();

fileInput.focus()​

Set focus on the component.

Definition
fileInput.focus()
Examples

Set focus on fileInput.

fileInput.focus();

fileInput.resetValue()​

Reset the current value to the default value.

Definition
fileInput.resetValue()
Examples

Reset the current value of fileInput.

fileInput.resetValue();

fileInput.setDisabled()​

Set the disabled value to toggle whether the input field is disabled. Defaults to true without a parameter.

Definition
fileInput.setDisabled(disabled)
Parameters

disabled​

Whether input, interaction, selection, or triggering is disabled.

Type boolean
Format True/False
Default
false
Examples
true

Examples

Disable fileInput.

fileInput.setDisabled(true);

Enable fileInput.

fileInput.setDisabled(false);

fileInput.setHidden()​

Set the hidden value to toggle whether the component is visible. Defaults to true without a parameter.

Definition
fileInput.setHidden(hidden)
Parameters

hidden​

Whether this object is hidden from view.

Type boolean
Format True/False
Default
false
Examples
true

Examples

Hide fileInput.

fileInput.setHidden(true);

Unhide fileInput.

fileInput.setHidden(false);

fileInput.setValue()​

Sets the value of the file picker.

Definition
fileInput.setValue(value)
Parameters

value​

The value.

Type string | number | boolean | object | array

Examples

Set the current value of fileInput to userValue.

fileInput.setValue(userValue);

fileInput.validate()​

Validates the value of the input field.

Definition
fileInput.validate()
Examples

Validate the value of fileInput.

fileInput.validate();

Events​

Events triggered by user interactions. You can configure event handlers in the IDE to trigger queries or other actions in response to events.

EventDescription
ChangeThe value is changed.