Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forms page in docs is incorrect about multipart/form-data #2515

Closed
jordanbtucker opened this issue Jun 16, 2024 · 0 comments · Fixed by #2516
Closed

Forms page in docs is incorrect about multipart/form-data #2515

jordanbtucker opened this issue Jun 16, 2024 · 0 comments · Fixed by #2516

Comments

@jordanbtucker
Copy link
Contributor

jordanbtucker commented Jun 16, 2024

There are a few issues with the accuracy of the Forms page, especially regarding multipart/form-data.

Forms can either submit as a GET request with URL search parameter encoding, or as a POST request with multipart/form-data.

This is not true. A form will submit a POST request (when its method attribute is set to post) with an application/x-www-form-urlencoded body by default. To submit a multipart/form-data request, its enctype attribute must be set to multipart/form-data.

The example given in the section POST request with multipart/form-data does not submit a multipart/form-data request. It submits a application/x-www-form-urlencoded request.

I can understand the confusion considering that MDN describes the FormData interface as using "the same format a form would use if the encoding type were set to "multipart/form-data", but that just refers to what happens if you provide a FormData as the body of a request made with fetch. When Deno provides a request to a route handler, its formData() function will resolve to a FormData that is built from the request's body, regardless if it's an application/x-www-form-urlencoded or a multipart/form-data body.

The second example, Handling file uploads, correctly sets the form's enctype to multipart/form-data since that is required for file uploads.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant