HTML & CSS
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?
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
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.
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.
Glad I could help!