> For the complete documentation index, see [llms.txt](https://openendpoints.gitbook.io/doc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://openendpoints.gitbook.io/doc/usage/web-form-with-file-upload.md).

# Web Form With File Upload

HTML web forms allow to send files along with the form data:

```html
<input type="file" name="foo" />

<!-- It is possible to upload multiple files using the multiple attribute: -->
<input type="file" name="foo" multiple="true" />
```

OpenEndpoints automatically understands the correct `enctype` to separate uploaded content from form `<input>` data:

| File Upload                            | enctype                           |
| -------------------------------------- | --------------------------------- |
| Web form with no file upload           | application/x-www-form-urlencoded |
| Web form with one or many file uploads | multipart/form-data               |

Once the file(s) have been uploaded by the user, the following options exist to do things with these files:

## Option 1 - Email attachment

The [Email Task](/doc/configuration/tasks/email-task.md) allows to add **all** uploaded files as attachments:

```xml
<attachments-from-request-file-uploads/>
```

That means: It is not possible to select which file should be attached as an attachment. All files are always attached.

## Option 2 - Insert file content into HTTP request body

When sending an HTTP request from OpenEndpoints using the [HttpRequest Task](/doc/configuration/tasks/httprequest-task.md) , and when specifying that HTTP request should contain an XML body, and when that XML is specified inline, the optional attribute `upload-files="true"` may be set.

For example:

```xml
<xml-body upload-files="true">
    <foo upload-field-name="xyz" encoding="base64"/>
</xml-body>
```

This syntax indicates that the element `<foo>` will be filled with the contents of the uploaded file with the filename "xyz". The encoding is always **base64**, **no other encodings are supported**.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://openendpoints.gitbook.io/doc/usage/web-form-with-file-upload.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
