Skip to main content

Multipart Forms

When browsers submit forms with file inputs, they encode the data as multipart/form-data — a format that bundles multiple fields (text and binary) into a single HTTP body. Prism parses this format natively, giving you typed access to each part.

How Multipart Works

A multipart request body is split by a boundary string into parts. Each part has headers (name, filename, content type) and a body. Prism handles the boundary parsing and gives you a clean array of parts.
Basic Multipart Parsing

Text Fields vs File Parts

The key difference: file parts have a filename, text fields don’t.
Separating Fields and Files

Contact Form Example

Contact Form with Attachment

HTML Form

Browser Form
For structured file upload handling with size limits and type validation, see File Uploads — it builds on top of multipart parsing with PrismUploadProcessor.
Each multipart part’s data property contains the raw bytes. For text fields, use stringValue which decodes the data as UTF-8. For files, work with data directly or use the upload processor.