---
title: "File"
description: "Add File control to your custom blocks for WordPress using the Lazy Blocks plugin."
url: "https://www.lazyblocks.com/docs/blocks-controls/file/"
lastUpdated: 2026-09-09
source: "blocks-controls/file.mdx"
---
# File

File control lets you upload and select files using the WordPress Media Library. The control stores file information as an array.

## Control Settings

- **Allowed Mime Types** (`allowed_mime_types`) - the file types the media picker accepts. Empty by default, and an empty list allows every type WordPress allows

The field is a multi-select over the file types WordPress allows uploading, so the choices are extension groups such as `jpg|jpeg|jpe`, `png` and `mp4|m4v` rather than free text.

## Saved Data

The control saves the following file information:

| Name      | Description                                 |
| --------- | ------------------------------------------- |
| `id`      | Unique ID of uploaded file                  |
| `url`     | URL to access the file                      |
| `alt`     | Optional alt attribute used in `<img>` tags |
| `title`   | Attachment title                            |
| `caption` | Optional caption                            |
| `link`    | Link to file                                |

## Usage

```php title="PHP" /$attributes['control_name']['url']/
<audio src="<?php echo esc_url( $attributes['control_name']['url'] ); ?>" controls>
</audio>
```

```hbs title="Handlebars" /{{control_name.url}}/
<audio src="{{control_name.url}}" controls>
</audio>
```

```php title="Post Meta" /get_lzb_meta( 'control_meta_name' )/
<?php
$file = get_lzb_meta( 'control_meta_name' );
?>
<audio src="<?php echo esc_url( $file['url'] ); ?>" controls>
</audio>
```

The control uses the native WordPress Media Library for file uploads and selection.

## Documentation Index
> Fetch the complete documentation index at: https://www.lazyblocks.com/llms.txt
> Fetch every page in a single file at: https://www.lazyblocks.com/llms-full.txt
