Home

enctype

Enctype is an attribute of the HTML form element that specifies how the submitted form data should be encoded when it is sent to the server. The encoding type primarily affects POST submissions, while for GET submissions the data are included in the URL query string and the enctype attribute is generally ignored.

The most common values are: application/x-www-form-urlencoded, which is the default. In this mode, form fields are

Usage guidelines: use application/x-www-form-urlencoded for standard forms without files, as it yields compact data and broad

Example: <form action="/upload" method="post" enctype="multipart/form-data">.

encoded
as
key=value
pairs
separated
by
ampersands,
with
certain
characters
escaped.
multipart/form-data,
which
is
required
for
forms
that
include
file
uploads;
the
data
are
sent
in
separate
parts,
allowing
binary
data
to
be
transmitted
safely.
text/plain,
which
sends
plain
text
without
key=value
encoding;
this
value
is
rarely
used
in
practice
and
is
not
widely
supported
by
servers.
A
form
may
specify
only
one
of
these
values
through
the
enctype
attribute,
and
some
servers
or
frameworks
expect
multipart/form-data
for
file
inputs.
compatibility.
Use
multipart/form-data
when
the
form
includes
input
type="file",
or
when
binary
data
must
be
transmitted.
The
text/plain
option
is
largely
obsolete
for
modern
web
applications.
The
enctype
attribute
is
defined
on
the
form
element,
and
it
works
in
conjunction
with
the
method
attribute
(most
commonly
method="post").
If
the
server
expects
a
specific
encoding,
the
form’s
enctype
should
be
set
accordingly,
and
server-side
code
must
parse
the
incoming
data
in
the
chosen
format.