Key facts
What does a file upload form need?
A file upload needs a <form> with method="post" and enctype="multipart/form-data", and an <input type="file"> with a name. Everything else is optional: accept and capture steer the picker, multiple allows several files, and size limits are up to your JavaScript and your server.
| Rule | What happens |
|---|---|
enctype="multipart/form-data" | Required. Without it the browser sends only the file's name, never its contents. |
method="post" | Required. A GET form puts the fields in the URL, and a file input adds only its filename. |
accept | A hint for the file picker only. It is not checked on submit, so check the type again on the server. |
multiple | Lets the user pick several files. Each one is sent as its own part under the same name. |
capture | With an image or video accept such as image/*, phones open the camera: user for the front camera, environment for the rear. Desktop browsers ignore it. |
| Maximum file size | There is no HTML attribute for it. Check File.size (in bytes) in JavaScript and enforce the limit on the server. |
| No file chosen | The field is still sent, as an empty part with filename="". |
fetch with FormData | Never set the Content-Type header yourself. The browser writes multipart/form-data with the boundary it used. |
Sources: WHATWG HTML Standard: enctype · WHATWG HTML Standard: constructing the entry list · WHATWG HTML Standard: file upload state · MDN: Using FormData objects · MDN: Blob.size




