Skip to main content

Upload files and images in mobile apps

Learn how to upload files and images in mobile apps.

Retool provides a number of components that enable users to upload files and images in mobile apps:

These components have several configuration options that allow you to control what users can upload.

The maximum supported file size for file uploads is 40MB.

Add file upload functionality

Add a File Input component to the canvas. This enables users to upload files from the mobile app.

Accepted file types

Use the File types option to specify the MIME types to allow for upload. Retool provides three categories of file types from which you can select.

The Documents option contains a list of MIME types for common file types, such as PDFs and Microsoft Word documents.

[
"text/*",
"application/*",
"application/pdf",
"application/msword",
"application/vnd.ms-excel",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"application/json",
"application/rtf",
"application/xml"
]

You can provide your own list of MIME types to accept. Click the button and specify an array of MIME type values.

Add image upload functionality

Add an Image Input component to the canvas. This button enables users to select an image to upload.

Input method

You can configure the Image Input component's Input method option to specify whether users can upload images from their device's photo library, capture and upload images with the camera, or allow the user to choose.

Resolution

To reduce file size and improve performance, Retool can scale images during upload. Select Low, Medium, or High to specify the resolution size to use. You can also prevent resolution changes with Original.

Compress photos

Retool can also compress images for file size and performance. Enabling this option results in images that are 50% smaller in size but with minimal loss of quality.

Single or multiple selection

You can specify whether users can upload a single image or multiple images.

If you allow multiple images, you can also specify a minimum or maximum number of images to allow.

Reference uploaded file and image data

Uploaded files are Base64-encoded. The File Input component's value property contains a Base64-encoded string of the file. You can reference Base64-encoded values anywhere in Retool that accepts a string value, including URLs. For example, you can set the URL of an Image component to {{ fileInput1.value }} to display an uploaded image.

The file property is an object with more information about the uploaded file.

NameTypeDescription
lastModifiednumberThe last modified date of the file, formatted as a Unix timestamp.
namestringThe name of the file.
sizenumberThe size of the file, in bytes.
typestringThe MIME type of file.
uriBase64 stringThe Base64 string encoding of the file.

Save uploaded files and images

You can reference value in queries to store files in a data store, such as Retool Storage or Amazon S3.

You can enable the Upload file to Retool Storage option for the component to automatically store the file in Retool Storage.