---
source: https://iinventedlight.com/library/notes/fastapi-uploads.md
title: "FastAPI file uploads - File, UploadFile and form fields"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "MIT (FastAPI docs); MIT (fastapi/fastapi (GitHub)); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: FastAPI docs, Request Files; fastapi/fastapi (GitHub), tutorial/request-files.md. MIT (https://raw.githubusercontent.com/fastapi/fastapi/master/LICENSE). Copyright FastAPI contributors."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-18
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-18
as_of: 2026-11-18
confidence: medium
untested: "Not reproduced (2026-11-18). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-web: fastapi uploads"
tags: [fastapi, uploadfile, forms, multipart, python]
client: Librarian
sources:
  - id: S1
    title: "Request Files"
    publisher: FastAPI docs
    url: https://fastapi.tiangolo.com/tutorial/request-files/
    accessed: 2026-11-18
    license: "MIT"
  - id: S2
    title: "tutorial/request-files.md"
    publisher: fastapi/fastapi (GitHub)
    url: https://github.com/fastapi/fastapi/blob/master/docs/en/docs/tutorial/request-files.md
    accessed: 2026-11-18
    license: "MIT"
---
# FastAPI file uploads - File, UploadFile and form fields
**Answer:** Uploaded files are sent as form data. Declare a parameter as `UploadFile` to receive a spooled file. It is stored in memory up to a size limit, and after that limit it is stored on disk.

## Examples

```python
from fastapi import FastAPI, File, Form, UploadFile

app = FastAPI()

@app.post("/upload")
async def upload(file: UploadFile = File(), title: str = Form()):
    data = await file.read()
    return {"filename": file.filename, "content_type": file.content_type, "n": len(data), "title": title}

@app.post("/uploads")
async def uploads(files: list[UploadFile] = File()):
    return [f.filename for f in files]
```

## Rules

- Install `python-multipart` first. Mix `File()` and `Form()` fields on the same path operation when needed.
- `UploadFile` provides metadata such as `filename` and `content_type`.

## See also

- [fastapi-dependencies](https://iinventedlight.com/library/notes/fastapi-dependencies/)
- [fastapi-middleware](https://iinventedlight.com/library/notes/fastapi-middleware/)

## Claims

- id: C1
  claim: Uploaded files are sent as form data.
  source: S1
  evidence: "uploaded files are sent as \"form data\""

- id: C2
  claim: A spooled file stays in memory up to a size limit.
  source: S2
  evidence: "A file stored in memory up to a maximum size limit"

- id: C3
  claim: The files are uploaded as form data.
  source: S2
  evidence: "The files will be uploaded as \"form data\""

## Sources

- [S1] Request Files. FastAPI docs. https://fastapi.tiangolo.com/tutorial/request-files/ . License: MIT. Accessed 2026-11-18.

- [S2] tutorial/request-files.md. fastapi/fastapi (GitHub). https://github.com/fastapi/fastapi/blob/master/docs/en/docs/tutorial/request-files.md . License: MIT. Accessed 2026-11-18.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: FastAPI docs, Request Files; fastapi/fastapi (GitHub), tutorial/request-files.md. MIT (https://raw.githubusercontent.com/fastapi/fastapi/master/LICENSE). Copyright FastAPI contributors. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
