Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
313 views
in Technique[技术] by (71.8m points)

html - What's the difference between content-type and enctype

For HTML forms. I am confused, I'm trying to set enctype='application/octet-stream' but the server receives the request with content-type ='application/x-www-form-urlencoded' (the default value).

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The enctype attribute specifies the content type (in HTTP terms, as indicated in Content-Type header) used by the browser when it submits the form data to server.

However, the spec defines only two content types in this context, application/x-www-form-urlencoded (the default) and multipart/form-data, and adds: “Behavior for other content types is unspecified.” What happens in practice is that browsers silently ignore enctype attributes with other values, using the default. You can see this if you e.g. inspect the document in Firebug: inspecting the form element, the DOM pane contains the property enctype—with the default value. It is common in web browsers to be silent about errors in markup.

The type application/octet-stream would not be very useful in this context, since if the browser sent such information, it would be effectively saying “this is lump of binary data of unknown (or unspecified) structure”.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...