How to use formenctype attribute in HTML?


The formenctype attribute is used to show how the form data should be encoded when it is submitting to the server. It introduced in HTML5 and only used with input type submit an image.

Here are the formenctype attribute values −

S.No
Value & Description
1
application/x-www-form-urlencoded
This is the default. All the characters are encoded before sent.
2
multipart/form-data
None of the characters are encoded.
3
text/plain
In this, the spaces are converted to + symbols. However, no special characters are encoded.


Example

You can try to run the following code to learn how to use the formenctype attribute in HTML.

<!DOCTYPE html>
<html>
   <head>
      <title>HTML formenctype attribute</title>
   </head>

   <body>
      <form action=”” method="post">
         Name<input type="text" name="name"/><br>
         <input type="submit" formenctype="multipart/form-data" value="Submit">
      </form>
   </body>
</html>

karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know

Updated on: 15-Jun-2020

118 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements