question about enctype

D

Daf

Hello,

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
point.

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. :)

Thanks
Daf
 
?

=?iso-8859-1?Q?brucie?=

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
point.

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

Methods GET and POST in HTML forms - what's the difference?
http://www.cs.tut.fi/~jkorpela/forms/methods.html
 
D

Daf

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

Methods GET and POST in HTML forms - what's the difference?
http://www.cs.tut.fi/~jkorpela/forms/methods.html

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.

Thanks
Daf
 
?

=?iso-8859-1?Q?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.

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
bottom.
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.

if you read the link supplied you would know.
 
H

Hywel Jenkins

Daf said:
Hello,

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
point.

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. :)

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
"multipart".

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.
 
A

Adrienne

Hello,

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 point.

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. :)

Thanks
Daf

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 ?
 
?

=?iso-8859-1?Q?brucie?=

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.

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 .
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
"multipart".

"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)
Is the problem in the form handler rather than the form itself.

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
enctypes.

[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.
http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.2
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,079
Messages
2,570,574
Members
47,207
Latest member
HelenaCani

Latest Threads

Top