---
title: "capture-file"
description: "Overview"
permalink: /docs/build/ui-components/all-ui-components/capture-file/
---
# capture-file

## Overview

<Info title={"Platform compatibility"}>

Compatible with all platforms. Web is only supported from version **4.80.0** of the JourneyApps Runtime.

</Info>

<Info>

The `capture-file` component was visually updated in version **4.80.0** of JourneyApps Runtime.

</Info>

The `capture-file` component allows users to upload a file from their device.

### Basic Example

**main.view\.xml**

```xml
<var name="current_file" type="attachment" media="application/pdf" />

<capture-file label="Upload signed document" bind="current_file" required="false" />
```

![](./media/spaces-2f9tchlr67elhbojpvhhud-2fuploads-2fgit-blob-a6b21e7fc9e9dfc98e173f32dea9538f88d4c662-2fcapture-file-example-e8ad04b9.png)

## Advanced Attributes

### `downloadable`

<SyntaxCard type="boolean" defaultValue="true" />

Set `downloadable` to `false` to hide the download button and prevent the user from downloading a captured/displayed file.

### `fullwidth`

<SyntaxCard type="boolean" defaultValue="false" />

Specify whether the file preview should span the full width of the available screen space.

### capture-file

```xml
<capture-file bind="report" label="Usage Report" fullwidth="true" />
```

![](./media/spaces-2f9tchlr67elhbojpvhhud-2fuploads-2fgit-blob-60ef521b1a64adff320d5b56bbe90809793c8f42-2fcapture-file-fullwidth-89d49215.png)

### display-file

```xml
<display-file bind="report" label="Usage Report" fullwidth="true"/>
```

![](./media/spaces-2f9tchlr67elhbojpvhhud-2fuploads-2fgit-blob-60ef521b1a64adff320d5b56bbe90809793c8f42-2fcapture-file-fullwidth-89d49215.png)

### `hide-filename`

<SyntaxCard type="boolean" defaultValue="false" />

Override the default and hide the captured/displayed filename from the preview.

### capture-file

```xml
<capture-file bind="report" label="Usage Report" hide-filename="true" />
```

![](./media/spaces-2f9tchlr67elhbojpvhhud-2fuploads-2fgit-blob-2d1cdaca6b4be48434e5516f3c03bdb3ed3376a7-2fcapture-file-hide-filename-6bac7c27.png)

### display-file

```xml
<display-file bind="report" label="Usage Report" hide-filename="true" />
```

![](./media/spaces-2f9tchlr67elhbojpvhhud-2fuploads-2fgit-blob-2d1cdaca6b4be48434e5516f3c03bdb3ed3376a7-2fcapture-file-hide-filename-6bac7c27.png)

### `align-content`

<AttributeReference label="align-content" href="/docs/build/ui-components/common-attributes/align-content/" badge="advanced" tone="muted" />

### `align-controls`

<AttributeReference label="align-controls" href="/docs/build/ui-components/common-attributes/align-controls/" badge="advanced" tone="muted" />

### `align-label`

<AttributeReference label="align-label" href="/docs/build/ui-components/common-attributes/align-label/" badge="advanced" tone="muted" />

### `control-order`

<AttributeReference label="control-order" href="/docs/build/ui-components/common-attributes/control-order/" badge="advanced" tone="muted" />

### `disabled`

<AttributeReference label="disabled" href="/docs/build/ui-components/common-attributes/disabled/" badge="advanced" tone="muted" />

### `icon-position`

<AttributeReference label="icon-position" href="/docs/build/ui-components/common-attributes/icon-position/" badge="advanced" tone="muted" />

### `id`

<AttributeReference label="id" href="/docs/build/ui-components/common-attributes/id/" badge="advanced" tone="muted" />

### `label-case`

<AttributeReference label="label-case" href="/docs/build/ui-components/common-attributes/label-case/" badge="advanced" tone="muted" />

### `label-color`

<AttributeReference label="label-color" href="/docs/build/ui-components/common-attributes/label-color/" badge="advanced" tone="muted" />

### `on-change`

<AttributeReference label="on-change" href="/docs/build/ui-components/common-attributes/on-change/" badge="advanced" tone="muted" />

### `show-if`

<AttributeReference label="show-if" href="/docs/build/ui-components/common-attributes/show-if/" badge="advanced" tone="muted" />

### `hide-if`

<AttributeReference label="hide-if" href="/docs/build/ui-components/common-attributes/hide-if/" badge="advanced" tone="muted" />

## Common Attributes

### `bind`

<AttributeReference label="bind" href="/docs/build/ui-components/common-attributes/bind/" />

### `label`

<AttributeReference label="label" href="/docs/build/ui-components/common-attributes/label/" />

### `required`

<AttributeReference label="required" href="/docs/build/ui-components/common-attributes/required/" />

## Component Methods

The following component methods are available when an [`id`](/docs/build/ui-components/common-attributes/id/) is assigned to the component and `component.captureFile({id:'my-id'})` / `component.displayFile({id:'my-id'})` is called from JS/TS:

### `captureMedia`

Programmatically open the file picker that enables the user to select and upload a file.

```javascript
try {
    component.captureFile({id: 'my-id'}).captureMedia();
} catch (e) {
    // handle exception here
}
```

### `closeMedia`

Programmatically close the file preview.

### capture-file

```javascript
try {
    component.captureFile({id: 'my-id'}).closeMedia();
} catch (e) {
    // handle exception here
}
```

### display-file

```javascript
try {
    component.displayFile({id: 'my-id'}).closeMedia();
} catch (e) {
    // handle exception here
}
```

### `deleteMedia`

Programmatically clear a captured file.

```javascript
try {
    component.captureFile({id: 'my-id'}).deleteMedia();
} catch (e) {
    // handle exception here
}
```

<Warning>

`deleteMedia` will trigger an [`on-change`](#on-change) if a function is assigned to it.

</Warning>

### `downloadMedia`

Programmatically trigger a download of the captured/displayed file.

### capture-file

```javascript
try{
    component.captureFile({id: 'my-id'}).downloadMedia();
} catch (e) {
    // handle exception here
}
```

### display-file

```javascript
try {
    component.displayFile({id: 'my-id'}).downloadMedia();
} catch (e) {
    // handle exception here
}
```

### `getMetadata`

Retrieve metadata about the captured file.

```javascript
try {
    var data = component.captureFile({id: 'my-id'}).getMetadata();
    console.log('metadata', data);
} catch (e) {
    // handle exception here
}
```

### `openMedia`

Programmatically open the file preview.

### capture-file

```javascript
try {
    component.captureFile({id: 'my-id'}).openMedia();
} catch (e) {
    // handle exception here
}
```

### display-file

```javascript
try {
    component.displayFile({id: 'my-id'}).openMedia();
} catch (e) {
    // handle exception here
}
```

### `scrollIntoView`

Programmatically scroll until the `capture-file` / `display-file` component is visible in the view.

### capture-file

```javascript
try {
    component.captureFile({id: 'my-id'}).scrollIntoView();
} catch (e) {
    // handle exception here
}
```

### display-file

```javascript
try {
    component.displayFile({id: 'my-id'}).scrollIntoView();
} catch (e) {
    // handle exception here
}
```
