zfcampus/zf-content-negotiation — pull request #18 by weierophinney (2014-05-31 15:17:12+00:00)
Title: Implement file uploads for PATCH and PUT requests

`multipart/form-data` is natively supported via POST by PHP. However, PATCH
and PUT are not; you need to parse the request body and separate the parts
into:

- form data
- file uploads

Additionally, for each file upload, you need to mimic how PHP uploads files,
and create a `$_FILES` compatible array.

This patch does the following:

- Adds support for parsing `multipart/form-data` request bodies, via
`Zend\Mime`.
- Injects any discovered form data parameters into the
`ParameterDataContainer`,
making them available later via the `bodyParam*()` plugins.
- Performs file uploads on any discovered files. This involves creating a
temporary file in either the `upload_tmp_dir` or system temporary directory
(depending on current configuration). Files are created using the prefix
`zfc`
to make them identifiable later. A `$_FILES`-compatible entry is created for
each upload, and injected into the response's files container.
- If any file uploads were discovered, it registers a listener on the "finish"
event to remove any files still remaining. The assumption is that you will
move or rename any upload files.