ASP: request.form is not returning value?

Classic ASP doesn’t provide built-in support for working with `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.

Leave a Comment