# File upload

This question type is used in cases where the responder needs to upload documents, such as a `pdfs` of contracts, certificates, prescriptions, etc.

If you would like to ask the responder take a picture of an ID card or themselves, you can use the[ image upload](/adding-questions-and-content/question-reference/image-upload.md) content type. If you would like the responder to sign a document, you can use the [signature ](/adding-questions-and-content/question-reference/signature.md)content type.

{% hint style="info" %}
If you don't want the responder to be held up by a file upload question, make sure to mark the question as [optional](/conditions-and-logic.md#optional).
{% endhint %}

### Managing File Storage

By default, Formsort securely stores uploaded files and images with our [data storage service](/saving-and-retrieving-responses.md) — no setup required.\
If you prefer to manage your own storage, you can optionally configure an **S3** or **GCS** bucket as a custom file destination.

To set up a custom integration, follow our detailed guides for:

* [Amazon S3 setup](/integrations/integration-reference/s3.md)
* [Google Cloud Storage setup](/integrations/integration-reference/google-cloud-storage.md)

### Creating a filename pattern

You can opt to define a naming pattern for the files that your responders upload by enabling **Filename pattern** in the question settings.&#x20;

Here, you can [template](/variable-templating.md) any relevant variable you would like to be included in the name of the file into the field. For example, if you type `{{first_name}}` into the field, the value of the `first_name` variable will be used as the filename at upload.&#x20;

Formsort also offers three custom variables for these types of file upload components, built right into the settings of the component itself: `sessionUuid`, `randomUuid`, and `currentTimeUTC`. These variables are also able be templated into the **Filename pattern** field to create dynamic filenames.

* `sessionUuid`: a uuid that is created **once**, when the form is loaded.&#x20;
* `randomUuid`: a uuid that is **created at and re-run** at each upload instance.&#x20;
* `currentTimeUTC`:  a timestamp that is **created at and re-run** at each upload instance.&#x20;

<div align="left"><figure><img src="/files/QxrTbJLavbtvTS09A0Bh" alt="" width="563"><figcaption></figcaption></figure></div>

You can use several of these variables at once, if required, and one pattern we suggest is `{{currentTimeUTC}}_{{responder_uuid}}`. This ensures uniqueness via the timestamp, while still tying the file to a particular user via the `responder_uuid` System Library variable.&#x20;

{% hint style="info" %}
Visit the [System Library variables](/response-data-collection-and-management/variable-schema/system-library-answers.md) section for details on built-in variables that provide information about the responder's environment and context.&#x20;
{% endhint %}

Note that these extensions will be added automatically. You should also set a fallback naming convention in case the variable is not defined by typing it into the **Filename pattern fallback** field. Values here cannot use templated variables.&#x20;

### Specifying file types allowed

You can whitelist [MIME (Multipurpose Internet Mail Extension) types](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types) by adding them to the **Allowed MIME types** field. Once a MIME type is whitelisted, the file upload will only accept that specific file type (as well as any other file type whitelisted).

The below is a list MIME types currently supported by the file upload component:&#x20;

| Category | MIME types                                                                                           |
| -------- | ---------------------------------------------------------------------------------------------------- |
| Images   | <p>image/gif</p><p>image/vnd.microsoft.icon</p><p>image/png</p><p>image/jpeg</p><p>image/svg+xml</p> |
| Video    | image/mp4                                                                                            |
| Document | application/pdf                                                                                      |

{% hint style="info" %}
You should whitelist MIME types, otherwise you may receive uploads of formats that you cannot process; i.e. if you want to allow *only* document uploads, whitelist the **application/pdf** MIME type.&#x20;
{% endhint %}

### **Allowing multiple answers**

Enabling **allow multiple uploads** lets the respondent upload more than one file as an answer to a question.&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.formsort.com/adding-questions-and-content/question-reference/file-upload.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
