question about enctype

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I help out with tech support for a php/mysql forum software company.
I've had a couple of cases that have me stumped and I was hoping one of you
might shed some light on this for me.

We use the form "post" method for posting (new thread, new poll, and edit).

Here is the comlplete form tag:

<form method="post" name="input" action="post.php?action=newthread&fid=
$fid" enctype="multipart/form-data">

Out of thousands of forums there will a couple that will not post the data
- the page just refreshes - the data is not sent.

IF I remove the "enctype="multipart/form-data" from the form tag it will
post normally - however the ability to attach images is broken at that

My question is: is this a server configuration issue? Do some servers not
support multipart/form-data?

I can't figure out what is happening when this occurs.

I would appreciate any insights. :)


Re: question about enctype

Daf said...

Quoted text here. Click to load it

the below link covers what you need to know and saves me repeating it

Methods GET and POST in HTML forms - what's the difference?

25/September/2003 08:30:45 pm

Re: question about enctype

Quoted text here. Click to load it

Thanks Brucie,
I know the difference between the 2 methods. I was hoping to learn
exactly what to tell these users to ask their hosts to enable/install in
order to use the post method with that enctype.
I think it's a server configuration issue but I don't know enough about
it, from the server side, to figure out what's not right.

Quoted text here. Click to load it

Re: question about enctype

Daf said...
Quoted text here. Click to load it

the link supplied provides the answer and additional information of
how everything fits and interacts together which your question
indicates you have no/little knowledge of. read the page from top to

Quoted text here. Click to load it

if you read the link supplied you would know.

26/September/2003 06:56:11 pm

Re: question about enctype

Quoted text here. Click to load it

You need to have the enctype set if you want to upload files.  Without
it the file data isn't send even though the form part is.  AIUI, the
"form-data" means "form and data" where the "form" part is what you've
filled in the fields, and the "data" part is the file itself, hence

Is the problem in the form handler rather than the form itself.  I'd
add break-points to the script to which the form submits to see how
far the script is getting.  Mind you, if the form simly refreshes it
may be a problem with the syntax of your <form> element.


Re: question about enctype

Hywel Jenkins said...

Quoted text here. Click to load it

the specs don't prohibit sending files with application/x-url-encoded
(the default enctype) but it has a few major problems that the
multipart/form-data enctype was introduced to solve. html was changed
at the same time to add type="file" so you could select the file/s
(comes in handy) and added the accept attribute .

Quoted text here. Click to load it

"multipart" means a series of parts. each part contains a content
disposition value of "form-data" and a parameter of "name".
"form-data" just means data from a form (whether a file or not) the
value of "name" is the original name used in the form element.

for example if sending a form with some text and a file

the headers would be:

POST /the-script.php HTTP/1.1
Content-length: 9999
Content-Type: multipart/form-data;
Posting 9999 bytes...
Content-Disposition: form-data; name="text";
[... the text ...]
Content-Disposition: form-data; name="file"; filename="blah.png"
Content-Type: image/png
[... the file ...]
(the other usual headers of host/accept/referer etc etc are also sent)
Quoted text here. Click to load it

the form has the wrong enctype[1] but the server script still needs to
know how to handle the way the file is submitted by the enctype used.

if you use "application/x-www-form-urlencoded" then the script needs
to know how to handle it. if you use "multipart/form-data" then the
script needs to know how to handle it. if it doesn't matter which
enctype is used then you can design your script to handle both

[1]The content type "application/x-www-form-urlencoded" is inefficient
for sending large quantities of binary data or text containing
non-ASCII characters. The content type "multipart/form-data" should be
used for submitting forms that contain files, non-ASCII data, and
binary data.

26/September/2003 10:21:22 pm

Re: question about enctype

<snipped long tech. info about posting forms>

Cheers ears - very useful.

Hywel     I do not eat quiche /

Re: question about enctype

Quoted text here. Click to load it

What is getting returned when you loop through the post/get value pairs?

Is the action attribute what you see when you view source, or is it the
actual coding?

If it's the coding it should be:
<form method="post" name="input" action="post.php?action=newthread&amp;fid=
<? echo $fid ?>" enctype="multipart/form-data">

Make sure there are no spaces between the = sign and the value, otherwise,
you will get a %20 which can mess up your script. Escape &'s.  That can
also lead to server side problems.

If that is the source, is post.php expecting a querystring value of $fid ?

Adrienne Boswell
Please respond to the group so others can share

Site Timeline