ASP.NET and newer technologies solved some problems that exist in Classic ASP.  One of those problems is how to get form variable data from a form with the attribute enctype set to “multipart/form-data”.

It’s necessary to set a form this way in order to use the file upload control in Classic ASP.  But what if you have other controls passing form variables you wish to access, such as drop downs and text areas?  The request.form object no longer behaves in the way you’d normally expect, and you cannot use “request.form(“controlName”).item to pull form variable data.

It would seem you can either upload files or send regular form data, but not both.

A resolution I came up with was to come up with a set of helper functions and page variable array variables to do the heavy lifting for me. After these functions have been implemented, what would have been

 

Becomes

 You’ll notice that there is another argument in FormDataElementInformation that does not exist in Request.Form and that the .item property is not used.  This second argument can be either “value”, “isfile”, or “filename”, and “name”.
Value:  The value of the form variable.  This is what you would normally have received from request.form(“controlName”).item.  This also contains the contents of any file upload control.
Isfile:  This is either true or false and can be used to determine if a control was an upload control or not.
Filename:  This returns the name of the file uploaded for an upload control.
Name:  This returns the name of the control.  This can be useful if you need the exact case of the control name.

So knowing how to use the FormDataElementInformation function, what code is required for its proper implementation other than setting the form’s enctype to “multipart/form-data”?

For troubleshooting purposes, you might want to have a handy function to spit out all your new form variables:

 

This function requires another helper function:

A caveat I would like to note is that this form solution has been tested in Internet Explorer and Firefox.  This does NOT work in Chrome. What might you have to do in order for this to work in Chrome?

Happy coding!

Like this post? Share it!