> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/gradio-app/gradio/llms.txt
> Use this file to discover all available pages before exploring further.

# File

> Create file upload and display components in Gradio

The File component allows users to upload files or display files for download.

## Basic usage

```python theme={null}
import gradio as gr

def process_file(file):
    return file.name

gr.Interface(
    fn=process_file,
    inputs=gr.File(),
    outputs=gr.Textbox()
).launch()
```

## Constructor

<ParamField path="value" type="str | list[str] | Callable | None" default="None">
  Default file(s) as filepath(s) or URL(s)
</ParamField>

<ParamField path="file_count" type="Literal['single', 'multiple', 'directory']" default="'single'">
  Upload mode:

  * `"single"` - One file
  * `"multiple"` - Multiple files
  * `"directory"` - All files in directory
</ParamField>

<ParamField path="file_types" type="list[str] | None" default="None">
  Allowed file types. Examples:

  * `["image"]` - Only images
  * `[".pdf", ".docx"]` - Specific extensions
  * `["video"]` - Only videos
</ParamField>

<ParamField path="type" type="Literal['filepath', 'binary']" default="'filepath'">
  Return format:

  * `"filepath"` - String path to temporary file
  * `"binary"` - Bytes object
</ParamField>

<ParamField path="label" type="str | None" default="None">
  Label displayed above component
</ParamField>

<ParamField path="height" type="int | str | float | None" default="None">
  Component height (with scrollbar if needed)
</ParamField>

<ParamField path="interactive" type="bool | None" default="None">
  Whether file upload is enabled
</ParamField>

## Events

* **change** - Triggered when file selection changes
* **select** - Triggered when file is selected
* **clear** - Triggered when files are cleared
* **upload** - Triggered when file upload completes
* **delete** - Triggered when file is deleted
* **download** - Triggered when file is downloaded

## Examples

### PDF files only

```python theme={null}
import gradio as gr

def read_pdf(file):
    return f"Uploaded: {file.name}"

gr.Interface(
    fn=read_pdf,
    inputs=gr.File(file_types=[".pdf"]),
    outputs=gr.Textbox()
).launch()
```

### Multiple files

```python theme={null}
import gradio as gr

def process_files(files):
    return [f.name for f in files]

gr.Interface(
    fn=process_files,
    inputs=gr.File(file_count="multiple"),
    outputs=gr.Textbox()
).launch()
```

### Binary mode

```python theme={null}
import gradio as gr

def get_file_size(file_bytes):
    return f"File size: {len(file_bytes)} bytes"

gr.Interface(
    fn=get_file_size,
    inputs=gr.File(type="binary"),
    outputs=gr.Textbox()
).launch()
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.