DocumentationStudioUploading files

Uploading files in a Smartform

The File Upload element lets the person filling in a Smartform attach files, for example receipts. This page describes the element from both sides: what you set in SmartForms Studio, what the person sees, and the limits that apply. The general list of element settings is in Items.


Set up a File Upload

  1. Open the Smartform in the designer and go to the section where the files belong.
  2. On the Items tab, add the File Upload element.
  3. Select it, open Properties, and fill in the settings:
SettingWhat it does
TextThe title shown in the upload box.
Helper textHelp text shown when the person points at the element.
Max size in mbThe most the files on this element may add up to, up to 10. The default is 10.
DescriptionThe line of text under the title, for example Drop receipts here or click to choose files.
Required fieldThe person must add at least one file before the form can be submitted.
Read onlyThe person cannot add files.
Prevent data insertFiles cannot be added through the API.
Restricted file typesTypes that this element refuses, chosen from a list.

The properties of a File Upload element: Max size in mb is 2, and Restricted file types is empty.


What the person sees

The element is a box with the title and the description. The person clicks the box and chooses a file, or drags a file onto it. The box takes one file at a time. Add a second file by choosing or dropping it again.

Each added file shows under Files uploaded, with a button to download it and a button to remove it.

A File Upload element with four numbered parts: the title, the description, the heading Files uploaded, and the name of an uploaded file with its download and remove buttons.

  1. The title of the element.
  2. The description.
  3. Files uploaded, shown once a file has been added.
  4. The file name, with buttons to download or remove it.

A file cannot be added to a form that is already completed.


Limits and checks

Three kinds of checks apply. The first two run in the browser and show a red message in the upload box. The third runs when the file is sent.

Size

The files on one element may add up to Max size in mb, and never more than 10 MB. The limit is checked when the person adds a file, against all the files already on the element plus the new one.

A File Upload with Max size in mb set to 2: adding a file of about 3 MB shows the message File size for all files needs to be less than 2 MB.

The server also checks each single file against the same limit. A file it refuses as too large gives the message Max size reached. Total file size exceeds the upload limit.

File type

Only these file types can be uploaded: .txt, .doc, .docx, .pdf, .jpg, .jpeg, .png, .gif, .bmp, .svg, .mp3, .wav, .ogg, .mp4, .avi, .mkv, .xls, .xlsx, .csv, .zip, .rar, .ppt and .pptx. Restricted file types takes types out of that list for one element. Every other type, such as .exe, is refused on every element.

When the type is not allowed, the upload box shows File type not accepted. Types accepted are: and the list of types this element accepts.

Adding a file with the extension .exe: the upload box lists the accepted types.

Content

When the file is sent, the server checks that its content really is what its extension says. A file that has been renamed is refused. For example:

  • A .pdf, an image, a Word, Excel or PowerPoint file, an audio or video file, or an archive must have the content of that type.
  • A .txt or .csv file must contain text.
  • An .svg file must be an SVG image.
  • A .docx, .xlsx or .pptx file must be a real Office document, and a .zip file that is really an Office document is refused.

The person then sees a short message in the top right corner: Failed to upload file.

A text file that was renamed to end in .pdf is refused: the message Failed to upload file shows in the top right corner.

Everything on the form

All the answers saved on one form, files included, may add up to about 16 MB. If the total is larger, the save is refused with Max size reached. Total file size exceeds the upload limit. This limit is for the whole form, not for one file.


All in one go

A File Upload with a 2 MB limit: a file that is too large is refused, a file with the wrong type is refused, and a small PNG image is accepted and listed under Files uploaded.

MessageCauseWhat to do
File size for all files needs to be less than N MBThe files on the element add up to more than Max size in mb.Remove a file, or add a smaller one. To allow more, raise Max size in mb, up to 10.
File type not accepted. Types accepted are:The extension is not on the list, or the element restricts it.Use one of the listed types.
Failed to upload fileThe content of the file does not match its extension.Save the file again in the right format and add it again.
Max size reached. Total file size exceeds the upload limit.All the answers on the form together are larger than about 16 MB, or the server refused one file as larger than Max size in mb.Remove files from the form, or add a smaller file.

To read the files of a record through the API, see the File Upload Value API in Smartforms API.