如何在使用 HTML 向服务器提交时指定是否对表单数据进行编码?
在 HTML 中使用 enctype 属性可以设置在向服务器提交表单数据时是否对该数据进行编码。
示例
你可以尝试运行以下代码来实现 enctype 属性 −
<!DOCTYPE html> <html> <body> <p>Which sports do you like?</p> <form action = "" method = "post" enctype = "multipart/form-data"> <input type = "checkbox" name = "vehicle" value = "football" checked> Football<br> <input type = "checkbox" name = "vehicle" value = "cricket" checked> Cricket<br> <input type = "checkbox" name = "vehicle" value = "hockey"> Hockey<br> <input type = "submit" value = "Submit"> </form> </body> </html>
广告