phantom007 — 2010-02-06T23:38:04-05:00 — #1
When uploading a file using HTML, we use the following method in the form tag
I know we use it when uploading file but I want to know what does it do? Why cannot we upload a file without this method?
dan_grossman — 2010-02-06T23:53:27-05:00 — #2
Because that's how the HTTP protocol says we do it It's called "multipart" because the HTTP request has "multiple parts" -- one for the main request body, one for the form data, one for each binary object, separated by multipart boundaries.
RFC 1867: Form-Based File Upload in HTML
Hypertext Transfer Protocol -- HTTP/1.1
cooper_semantics — 2010-02-06T23:55:51-05:00 — #3
autisticcuckoo — 2010-02-07T01:47:24-05:00 — #4
The default encoding type,
application/x-www-form-urlencoded, lists field names and values similar to how they appear in the query parameters in a GET request. For instance,
POST /form.php HTTP/1.1
As you can see, this type of encoding is not useful for uploading files, because files can contain any character.
multipart/form-data encoding the POST request body is split into multiple parts. Each part is delimited by a special identifier string, which makes it possible for the receiving application to detect the end of the uploaded file's content.
phantom007 — 2010-02-07T02:15:21-05:00 — #5
Now that is what I call an "answer"
many thanks AutisticCuckoo, your 2 minute effort helped me understand the concept and saved an hour of mine from reading a 3 page confusing article.
autisticcuckoo — 2010-02-07T14:57:34-05:00 — #6
Glad I could help!