Hi
When uploading a file using HTML, we use the following method in the form tag
multipart/form-data
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?
Thanks
Hi
When uploading a file using HTML, we use the following method in the form tag
multipart/form-data
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?
Thanks
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.
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
Host: www.example.com
name=Jane&age=42&skills=html,css
As you can see, this type of encoding is not useful for uploading files, because files can contain any character.
With a 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.
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.
Thanks again
Glad I could help!