I have following form,
Don't use enctype="multipart/form-data"
Remove that from the code and see if it works. The form-data enctype
is used for uploading data, for example image files. You need to access the form elements slightly differently if you use that enctype
.
If you are uploading data, then the ASP object you are using (for example ASP Upload
) will have functions to access form fields. Request.form("")
wont work.
Accessing the form values would be along the lines of:
Set yourUploadComponent = CreateObject("Your.UploadComponentClassString")
sFormValue = yourUploadComponent.Form.Item("txtName").Value
You will need to read the objects documentation.
Classic ASP doesn't support multipart/form-data
. This is a surprisingly basic deficiency even for a language of ASP's venerable age, but what're you gonna do about it, move to ASP.NET? (Yes? oh. well never mind then.)
If you aren't doing file uploads, it's easiest just to stick with the default enctype
(which is application/x-www-form-urlencoded
). The only advantage of multipart/form-data
is that you can put file uploads in it. (Theoretically, it would also have the advantage that you can specify character encodings definitively. But no browser actually does that.)
If you do need to handle multipart/form-data
in Classic ASP you will need to parse the incoming request body yourself, splitting it into fields and values. Or rather, more typically, use an existing library to do it*.
That library will usually provide separate interfaces for reading the uploaded files and the other form values. This completely replaces use of the Classic ASP Request.Form
interface. Exactly where you can find it depends on the library you choose. This does mean that if you want to have a form that can respond to either enctype
equally you have to check the type and use one of the two different interfaces.
*: There are loads. for example. I'm not endorsing either of these as such... neither of them actually parse multiparts properly as per the standard and both seem a bit lax about filename security (never store a file under the user-submitted filename! security disaster!). But that seems to be par for the course for ASP upload scripts. At least, unlike many, they're not asking money for them.
I found by removing enctype
completely (which defaults to application/x-www-form-urlencoded
) from the form tag that Request.Form("SomeInputTagId")
worked fine with method="post"
. I also didn't need to install any third party readers. Hope this helps.