您好,欢迎访问一九零五行业门户网

在HTML中,enctype='multipart/form-data'是什么意思?

使用 enctype 属性来指定浏览器在将数据发送到服务器之前如何对数据进行编码。可能的值有 -
application/x-www-form-urlencoded − 这是大多数表单在简单场景中使用的标准方法。
mutlipart/form-data − 这用于在表单中上传二进制数据,如图像、word文件等。
example现在让我们来看一个例子−
<!doctype html><html><head> <title>html enctype attribute</title> <style> form { width: 70%; margin: 0 auto; text-align: center; } * { padding: 2px; margin: 5px; } input[type=button] { border-radius: 10px; } </style></head><body> <h1>login</h1> <form enctype=multipart/form-data action= method=post> <fieldset> <legend>enter the login details</legend> <label for=emailselect>email id: <input type=email id=emailselect> <input type=button onclick=getuseremail('abc') value=abc> <input type=button onclick=getuseremail('pqr') value=pqr><br> <input type=button onclick=login() value=login> </label> <div id=divdisplay></div> </fieldset> </form> <script> var divdisplay = document.getelementbyid(divdisplay); var inputemail = document.getelementbyid(emailselect); function getuseremail(username) { if (username === 'abc') inputemail.value = 'abc@mnc.com'; else inputemail.value = 'pqr@mnc.com'; } function login() { if (inputemail.value !== '') divdisplay.textcontent = 'successful login. hello ' + inputemail.value.split(@)[0]; else divdisplay.textcontent = 'enter email id'; } </script></body></html>
登录并显示结果 −
以上就是在html中,enctype='multipart/form-data'是什么意思?的详细内容。
其它类似信息

推荐信息