Skip to main content

File Upload Widget

The File Upload widget allows users to upload one or multiple files to your application with advanced configuration options for file validation, storage, and user experience.

OverviewDirect link to Overview

The File Upload widget provides a robust file upload interface with support for:

  • Multiple file uploads
  • File type validation
  • File size limitations
  • Drag and drop functionality
  • Cloud storage integration (AWS S3)
  • Custom styling and validation
File Upload Widget

Basic ConfigurationDirect link to Basic Configuration

Global SettingsDirect link to Global Settings

NameDirect link to Name

  • Field: Name
  • Description: Display name for the widget
  • Type: Text input
  • Required: Yes

Variable/ModelDirect link to Variable/Model

  • Field: Variable/Model
  • Description: The data model property that will store the uploaded files array
  • Type: Text input
  • Required: Yes
  • Example: uploadedFiles
File Upload Global Settings

Upload ConfigurationDirect link to Upload Configuration

File LimitDirect link to File Limit

  • Field: Limit
  • Description: Maximum number of files that can be uploaded
  • Type: Text input (a number). A value that is not a number counts as an empty field: no limit, with no message
  • Default: 10 on a new widget. Leave the field empty for no limit
  • Example: 5 (allows up to 5 files)

File TypesDirect link to File Types

  • Field: File types
  • Description: Types of files the user can add. The file selection window offers these types, and each file is checked before it is sent
  • Type: Text input
  • Format: Comma-separated list of exact MIME types (application/pdf), families (image/*) or extensions (.pdf). Leave the field empty to accept every type
  • Examples:
    • image/* (all image types)
    • image/jpeg,image/png,image/gif (specific image types)
    • application/pdf (PDF files only)
    • .pdf,.docx (by extension)
    • image/*,.pdf (images and PDFs)
  • Reference: MDN MIME Types

Since version 8.6, families and extensions are really checked. Before, only an exact MIME type matched, so image/* refused every file.

Browsers do not always know the MIME type of a file: for unusual formats, prefer the extension. In Drag'n Drop mode, a dropped file of another type is ignored, with no message. Files dropped on the zone go through a stricter check than the button or a click on the zone:

  • Office types and other MIME types with a dot: an entry that contains a dot is read as an extension. With application/vnd.ms-excel or application/vnd.openxmlformats-officedocument.wordprocessingml.document, even a file of the right type is ignored when dropped: use the extension in lower case (.xls, .docx).
  • Upper-case extensions: extensions are compared with their case. With .pdf, REPORT.PDF is ignored when dropped. Add the other form (.pdf,.PDF) or use the MIME type (application/pdf).

File SizeDirect link to File Size

  • Field: File size
  • Description: Maximum file size allowed per file, checked when the file is selected. Leave the field empty for no check in the widget
  • Type: Text input (a number). A value that is not a number, such as 5MB, counts as an empty field: no check, with no message
  • Unit: Bytes
  • Example: 26214400 (25MB in bytes)
  • Note: Server limit is 25MB by default. It applies even if this field is empty, with its own message

Upload InterfaceDirect link to Upload Interface

Drag and DropDirect link to Drag and Drop

  • Field: Drag'n Drop
  • Description: Enable drag and drop file upload interface
  • Type: Toggle switch
  • Default: Disabled
  • When Enabled: Shows a drop zone with upload icon
  • When Disabled: Shows a button for file selection

Button TextDirect link to Button Text

  • Field: Button
  • Description: Text displayed on the upload button
  • Type: Text input
  • Default: "Cliquer pour uploader"
  • Example: "Upload Images"

Tip TextDirect link to Tip Text

  • Field: Tip
  • Description: Helper text displayed below the upload area
  • Type: Text input
  • Default: "Fichiers avec une taille inférieure à 25Mo"
  • Example: "Supported formats: JPG, PNG, PDF. Max size: 25MB"

These two default texts are in French, whatever the language of the page. Replace them on a page in another language, or translate them in the dictionary of the page.

AWS S3 StorageDirect link to AWS S3 Storage

  • Field: Store in S3
  • Description: Store uploaded files in AWS S3 bucket instead of local storage
  • Type: Toggle switch
  • Default: Enabled on a new widget
  • Requirements: S3 bucket must be configured in your account
  • Note: Without an S3 configuration, the file goes to the regular storage

Public File AccessDirect link to Public File Access

  • Field: Public file
  • Description: Make uploaded files publicly accessible
  • Type: Toggle switch
  • Default: Disabled
  • Effect: Files can be accessed without authentication
File Upload Configuration

Validation and RulesDirect link to Validation and Rules

Built-in ValidationDirect link to Built-in Validation

The widget automatically validates, when a file is selected:

  • File type against the accepted types
  • File size against maximum size limit
  • Number of files against the limit

Each check gives its own message: a file of the wrong type is not also reported as too big. See Error Handling.

Custom Validation RulesDirect link to Custom Validation Rules

You can add custom validation rules in the Rules section. In a Custom rule, write a JavaScript condition where SF_input holds the list of files, for example SF_input.length >= 2 to ask for two files at least.

Screen-based ValidationDirect link to Screen-based Validation

Configure widget behavior per screen in the Validation section:

  • Available: Show/hide widget on specific screens
  • Visible: Control visibility with conditions
  • Required: Make field required on specific screens
  • Disable: Disable widget on specific screens
File Upload Validation Rules

Styling and LayoutDirect link to Styling and Layout

Basic StylingDirect link to Basic Styling

  • Width: Set widget width (CSS units)
  • Class: Add custom CSS classes
  • Dynamic Classes: Set classes based on conditions
File Upload Styling

Events and ActionsDirect link to Events and Actions

On Change EventDirect link to On Change Event

  • Field: On Change (Action on field change)
  • Description: Action executed when files are uploaded/removed
  • Context: Access uploaded files via the model variable
  • Available Variables:
    • SF_input.value: The list of files of the widget
    • SF_input.SF_currentIndex: Index in loop contexts

The drawer that opens is titled On Click, as for every widget: here, it holds the action of the field change.

File Upload Actions

Usage ExamplesDirect link to Usage Examples

Basic File UploadDirect link to Basic File Upload

One image of 5 MB at most: Limit 1, File types image/*, File size 5242880.

File Upload Basic

Document Upload with Multiple FilesDirect link to Document Upload with Multiple Files

Up to 10 PDF files or images of 25 MB each, in Drag'n Drop mode.

File Upload Multiple

S3 Storage ConfigurationDirect link to S3 Storage Configuration

Images and videos stored in S3 (Store in S3) and readable without signing in (Public file).

File Upload Storage

Advanced ConfigurationDirect link to Advanced Configuration

Conditional VisibilityDirect link to Conditional Visibility

Set the widget to show/hide based on other form values: click Advanced Setting in the Validation section, then the pencil of Visible. In this example, the widget is only visible when needs_document is true:

File Upload Advanced Configuration

Error HandlingDirect link to Error Handling

Common Error ScenariosDirect link to Common Error Scenarios

The messages are shown in the language of the page. This table gives the English wording:

SituationMessage
File Type Not Accepted (File types)"Type file not acceptable!"
File Too Large (File size)"File size can not exceed [maxSize] Bytes!"
Too Many Files (Limit)"Limit is [limit] files !!"
File Refused by the Server: HTTP 413, or no answer at all"The size of the file to be downloaded exceeds the 25MB limit."
Any Other Server Error"Server side error!"

Before version 8.6, every server failure showed the 25MB message, whatever its cause, and these messages were not translated.

Best PracticesDirect link to Best Practices

  1. File Limits: Set reasonable file limits based on your server capacity
  2. User Feedback: Always provide clear tip text about accepted formats and sizes
  3. Validation: Use both client-side and server-side validation
  4. Storage: Consider using S3 for better performance and scalability
  5. Security: Be cautious with public file settings
  6. UX: Use drag and drop for better user experience
  7. Error Messages: Provide clear, actionable error messages

Integration NotesDirect link to Integration Notes

  • Files are automatically uploaded to /api/v1/files/fileupload or /api/v1/files/fileupload-s3
  • The widget integrates with the project's file management system
  • Uploaded files are associated with the current project ID
  • File metadata is stored in the specified model variable as an array