Skip to content
Related Articles

Related Articles

Improve Article

How to specify the form-data should be encoded when submitting it to the server in HTML5?

  • Difficulty Level : Expert
  • Last Updated : 21 May, 2021

In this article, we will specify the form-data should encoding when submitting it to the server by using the enctype attribute in the <form> element in the HTML document. This property specifies the data that will be present in the form that should be encoded when submitting to the server. This property is used to save sensitive user data from a third party. 

Syntax:

<form enctype = "value">

Note: This property can be used only if the method is “POST”

Value: It accepts two value

  • application/x-www-form-urlencoded: It has the default value. It is used to convert all the characters before sent to the server. It encodes the special characters to their hex values.
  • multipart/form-data: It does not encode any plain text and special characters and only convert whitespaces into + symbols.

Example: 



HTML




<!DOCTYPE html>
<html>
<body style="text-align:center">
    <h2 style="color:green">GeeksforGeeks</h2>
    <b>Form-data encoding when submitting it to the server in HTML5</b>
      
<p></p>
  
    <form action="#"
        method="post"
        enctype="multipart/form-data">
        First name:
        <input type="text"
            name="fname"><br/>
        <br> Last name:
        <input type="text"
            name="lname"><br/>
        <br>   Address:
        <input type="text"
            name="Address"><br/>
        <br>
        <input type="submit"
            value="Submit">
    </form>
</body>
  
</html>

Output:

Attention reader! Don’t stop learning now. Get hold of all the important Comcompetitivepetitve Programming concepts with the Web Design for Beginners | HTML  course.




My Personal Notes arrow_drop_up
Recommended Articles
Page :