views:

347

answers:

2

Update: The problem ended up being the Flash component itself. It wasn't properly compiling the multiple values from the element. I notified the developers and they implemented a workaround. Commons FileUpload does support multiple values per the accepted answer.

I have a form, enctype="multipart/form-data", with one

<select name="XX" multiple="multiple">

and a Flash upload component which allows the user to select multiple files. When handling the POST using Apache Commons FileUpload, I detect the select field via

item.isFormField() == true

and continue to extract the details via

// Process a regular form field
if (item.isFormField()) {
    String name = item.getFieldName();
    String value = item.getString();
}

The problem I'm having is that item.getString(); returns only the first selected value from the select field; no matter how many items I pick, I only get the first item.

Likewise, when I use the standard servlet method for parameter extraction, ie.

final String[] values = request.getParameterValues("XX");

values is empty, which I assume is because the form is encoded multipart.

How can I retrieve these multiple selected values from my multi-select field?

This (unanswered) question has also been posed on the Sun forums by another author.

+2  A: 

In fact, several items can have the same fieldName, you just have to add all the item string values for the same fieldName to a collection of String and then convert that collection to an array.

Found some information there : http://www.nabble.com/RES%3A-File-Upload-td25910926.html

mably
A: 

Which flash upload component you are using..? basically i do have the same requirement but not able to get the correct flash upload component.

jay
http://www.element-it.com/multipowupload.aspxI'm really happy with it and the developer had very quick turnaround from the time I first reported the bug to putting out a fixed version for me.
rcampbell

related questions