File upload with ServletFileUpload’s parseRequest? [duplicate]

As I said in a comment to the same question, you posted earlier, this is most likely because you have parsed the request already before.
The files are part of the request body and you can parse it only one time.

Update:

I usually do use commons-upload in that way:

if (ServletFileUpload.isMultipartContent(request)) {
    ServletFileUpload fileUpload = new ServletFileUpload();
    FileItemIterator items = fileUpload.getItemIterator(request);
    // iterate items
    while (items.hasNext()) {
        FileItemStream item = items.next();
        if (!item.isFormField()) {
            is = item.openStream();
        }
    }
}

Leave a Comment