How to let visitors upload and store files (Runtime Storage)
In a TeleportHQ web app, files your visitors upload, such as a CV or a photo for a custom cake, are saved by the Upload File(s) workflow step into your project's Runtime Storage. The usual setup is a File Upload Field inside a form, plus a form-submit workflow that uploads the chosen files. You can see every uploaded file in the Assets Manager under Uploads → Runtime Storage.
Before you start
- Uploads need workflows, so your project must be a web app. The File Upload Field itself works on any website; the workflow that saves the files makes the project a web app. See What is a web app in TeleportHQ?.
- The form's File Upload Field needs its own page state (a list) to hold the chosen files. See How to store and use values with States.
- Storage space depends on whether the web app has a Web App slot. See Good to know below.
Steps
This example lets bakery customers attach a photo of the cake design they want to the Order cake form.
1. Add the upload field to the form
- Create a page state for the files, for example
designPhotos, as a list (array). - Add a File Upload Field inside the Order cake form. See How to let visitors upload files in a form.
- With the field selected, in the right panel, open File Upload Field Settings:
- State: choose
designPhotos. - Multiple Files: turn on to allow several files.
- Accept: type
image/*to allow only images. - Label: type
Upload your cake design.
- State: choose
Nothing is uploaded when a visitor picks a file. The files wait in the state until the form's workflow uploads them.
2. Upload the files when the form is sent
- Select the form. In the right panel, in the Workflows section, click More event types (the ⋯ button), then On Form Submit in Select Event Type. TeleportHQ creates a workflow that starts with Form is Submitted and opens it. See How to run a workflow when a button is clicked.
- Click the round + (Add node) below the trigger. Point at State and click Get Local State. Set State Property to
designPhotos. - Below it, add Upload File(s) from File Storage.
- In File(s), use the result of Get Local State from the Context panel. See How to use data from one workflow step in the next.
- Optional: set Allowed MIME Types, for example
image/jpeg, image/png, and Max File Size in bytes, for example5242880for 5 MB. - Optional: add Create Item to save each file's File URL with the order. See How to save, update or delete database records with a workflow.
- Optional: add Update Local State to empty
designPhotosafter the upload. TeleportHQ doesn't empty it by itself, so the files would otherwise stay picked. - Publish your site.
Check that it worked
- On your published site, attach a photo and send the form.
- In the editor, in the left sidebar, open the Assets Manager and click the Uploads tab.
- Click the Runtime Storage card. The Runtime Storage panel opens next to it. The new file appears under Files, and Storage Usage shows the space used. Use the Download button to open a file.
Troubleshooting
Runtime Storage says "No files yet" "Files uploaded by your application's users will appear here." No upload has run on your live site yet. Check that you published after adding the workflow, and that the Upload File(s) step gets the files from the state.
"Failed to load files" The list couldn't load. Click Retry.
The field shows "<state name> (missing)" The state it used was deleted or renamed. Pick an existing state under State, or create a new one. Each upload field needs its own state.
Uploads stop working once storage is full The web app reached its storage limit. This only happens to a web app without a Web App slot. Delete files you don't need with a Delete File step, or give the project a slot. See Why does my web app need a slot, and what is the 7-day window?.
Good to know
- Storage space: a web app with a Web App slot has no storage limit. The trial and Premium include one slot, and you can buy more. Its Runtime Storage panel shows the badge Dynamic and "no storage limit on this project". A web app without a slot, during its 7-day window, has a limited space, and the panel shows how much of it is used. See Why does my web app need a slot, and what is the 7-day window?.
- Other upload steps: List Files lists stored files, Get File Details reads one, and Delete File removes one permanently.
- Without a form: add Pick File(s) from Browser to a button's On Click workflow, then pass its result to Upload File(s).
- Who can open uploaded files: each upload returns a File URL, a plain web address with no sign-in and no expiry. Anyone who has the link can open the file. Don't ask visitors to upload passwords, ID documents or other confidential files.
- Files uploaded by visitors are separate from the images and files you upload yourself in the Assets Manager. See What is the Assets Manager?.