> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.doc-detective.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.doc-detective.com/_mcp/server.

# upload

> Set the files of a file input, without opening the file dialog.

The `upload` action sets the files of a file input (`<input type="file">`). It replaces any files the input already holds. The operating system's file dialog never opens, so the step runs unattended and headless.

Use it for a procedure step such as "Choose your avatar image". A `click` on a file input fails, and `type` can't fill one.

> For comprehensive options, see the [`upload`](/reference/schemas/upload) reference.

## Properties

`upload` takes an object with `path` and at least one field that finds the element.

| Field                                                                           | Type                                 | Description                                                                                                                                                                                                     | Default            |
| ------------------------------------------------------------------------------- | ------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ |
| `path`                                                                          | string or array of strings           | **Required.** File or files to set. A relative path resolves against the spec file, unless [`relativePathBase`](/reference/schemas/config) is `cwd`. Use an array only for an input that accepts several files. |                    |
| `selector`                                                                      | string                               | CSS or XPath selector of the file input or its label.                                                                                                                                                           |                    |
| `elementText`                                                                   | string                               | Display text of the file input's label.                                                                                                                                                                         |                    |
| `elementId`, `elementTestId`, `elementClass`, `elementAttribute`, `elementAria` | as in [`click`](/docs/actions/click) | Other ways to find the file input or its label. The element must match every field you set.                                                                                                                     |                    |
| `frame`                                                                         | string or array of strings           | Selector of the iframe that holds the input. See [Elements inside an iframe](/docs/actions/find#elements-inside-an-iframe).                                                                                     | The top page       |
| `timeout`                                                                       | integer                              | Milliseconds to wait for the element. `0` checks once.                                                                                                                                                          | `5000`             |
| `surface`                                                                       | string or object                     | The browser window or tab to use. See [Test across multiple tabs, windows, and browsers](/docs/test-docs/multiple-tabs-and-windows).                                                                            | The active surface |

## Find the input

Many pages hide the file input and style its label as a button. `upload` works with a hidden input, so you can target either one:

* The input, with `selector`, `elementId`, or `elementTestId`.
* The label, with `elementText`. The step then uses the input that belongs to the label.

Some pages open the dialog from a script instead, so the button you see isn't a label. Target the input itself, which is often hidden near the button.

A drop zone works when it has a file input behind it. If it has no file input, `upload` can't fill it.

## Platform support

`upload` works in desktop browsers. In a mobile browser, the step is `SKIPPED`, because the file isn't on the device.

## Outputs

| Output  | Description                            |
| ------- | -------------------------------------- |
| `found` | Whether the element exists.            |
| `files` | Absolute paths of the files, in order. |

## Failures

| Message                                                                                           | Fix                                                                 |
| ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------- |
| ``Couldn't upload `/abs/avatar.png`: the file doesn't exist.``                                    | Check `path`. A relative path resolves against the spec file.       |
| ``Couldn't upload: the element isn't a file input. Set `selector` to the `<input type="file">`.`` | Target the input instead of the button that opens the dialog.       |
| ``Couldn't upload 2 files: the file input accepts one. Set `path` to one file.``                  | Set one file, or check that the input has the `multiple` attribute. |

## Examples

### Upload one file

```json
{
  "steps": [
    { "goTo": "https://app.example.com/profile" },
    { "upload": { "selector": "#avatar", "path": "avatar.png" } },
    { "find": "avatar.png" }
  ]
}
```

### Upload several files through a label

```json
{
  "steps": [
    { "goTo": "https://app.example.com/expenses" },
    { "upload": { "elementText": "Choose files", "path": ["receipt-1.pdf", "receipt-2.pdf"] } },
    { "find": "receipt-2.pdf" }
  ]
}
```