# File upload

Before version 2.1, CherryPy handled file uploads by reading the entire file into memory, storing it in a string, and passing it to the page handler method. This worked well for small files, but not so well for large files.

CherryPy 2.1 uses the python `cgi` module to parse the POST data. When a file is being uploaded, the `cgi` module stores it in a temp file and returns a `FieldStorage` instance which contains information about this file. CherryPy then passes this `FieldStorage` instance to the method. The `FieldStorage` instance has the following attributes:

- `file`: the file(-like) object from which you can read the data
- `filename`: the client-side filename
- `type`: the content-type of the file