A developer uses the 'multipart/form-data' Content-Type for file uploads. Why is this required instead of 'application/x-www-form-urlencoded'?
- A.multipart/form-data is required for HTTPS requests; x-www-form-urlencoded only works over HTTP
- B.multipart/form-data encrypts file contents before sending
- C.Binary file data cannot be URL-encoded efficiently; multipart/form-data separates each field (including file contents and metadata) into distinct sections with a boundary delimiter, allowing binary data to be transmitted accurately
- D.x-www-form-urlencoded cannot be used with POST requests
Why C is correct
application/x-www-form-urlencoded percent-encodes all characters, making it inefficient for binary content (a 1 MB image becomes 3 MB when encoded). multipart/form-data splits the body into parts separated by a boundary string, allowing raw binary data from files to be included alongside text fields. File upload security requires validating file type, size, and content server-side regardless of encoding.
Know someone studying for Web App Fundamentals? Send them this one.