3
votes

I wonder if it is possible to use both enctype="multipart/form-data" and a select multiple. Here is the drill:

I have this html file (test.html):

<form action="action.asp" method="post" enctype="multipart/form-data" name="form1">

    <select multiple name="prof">

        <option value="1">First</option>
        <option value="2">Second</option>
        <option value="3">Third</option>

    </select>

    <input type="submit" value="Ok" name="Ok">  

</form>

When I select any of those options on my list, my action page doesn't show anything (action.asp):

<%

dim prof

prof = request.form("prof")

response.write prof 

%>     

But if I remove the enctype="multipart/form-data" in test.html, then it works.

The problem is that I am using an asp upload file component that requires this enctype="multipart/form-data". Any sugestions?

Thanks in advance.

2
If you are using the ASPUpload component, check this : stackoverflow.com/a/12615143/1682881 - Flakes
That is a nice solution indeed, but I'm not using the ASPUpload component. - Sambarilove

2 Answers

1
votes

Finally found a bug on FileUploader class. The mcolFormElem Dictionary variable does not add the name/value pairs if already exist on the collection for the <select multiple> element, I have added the below code and working fine.

If Not mcolFormElem.Exists(LCase(sInputName)) Then 
                mcolFormElem.Add LCase(sInputName), CWideString(MidB(biData, nPosBegin, nPosEnd-nPosBegin))
            else
                dim tempKeyVal
                tempKeyVal=mcolFormElem.item(LCase(sInputName))
                mcolFormElem.Remove(LCase(sInputName))
                mcolFormElem.Add LCase(sInputName), tempKeyVal&","&CWideString(MidB(biData, nPosBegin, nPosEnd-nPosBegin))
            end if
0
votes

if your using enctype="multipart/form-data" it must be because you are uploading a file. if you upload a file you should be using a upload component if you do you could use :

Set yourUploadComponent = CreateObject("Your.UploadComponentClassString")
sFormValue =yourUploadComponent.Form.Item("prof").Value