Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to retrieve multiple values from the select field using Commons File Upload?
    text
    copied!<p><strong>Update:</strong> 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.</p> <p>I have a form, <em>enctype="multipart/form-data"</em>, with one </p> <pre><code>&lt;select name="XX" multiple="multiple"&gt; </code></pre> <p>and a Flash upload component which allows the user to select multiple files. When handling the POST using Apache Commons FileUpload, I detect the <em>select</em> field via </p> <pre><code>item.isFormField() == true </code></pre> <p>and continue to extract the details via</p> <pre><code>// Process a regular form field if (item.isFormField()) { String name = item.getFieldName(); String value = item.getString(); } </code></pre> <p>The problem I'm having is that <strong>item.getString();</strong> returns only the first selected value from the <em>select</em> field; no matter how many items I pick, I only get the first item.</p> <p>Likewise, when I use the standard servlet method for parameter extraction, ie.</p> <pre><code>final String[] values = request.getParameterValues("XX"); </code></pre> <p>values is empty, which I assume is because the form is encoded multipart.</p> <p>How can I retrieve these multiple selected values from my multi-select field?</p> <p>This (unanswered) question has also been <a href="http://forums.sun.com/thread.jspa?threadID=5395587" rel="nofollow noreferrer">posed on the Sun forums</a> by another author.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload