Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The Commons <code>FileUpload</code> package makes it easy to add robust, high-performance, file upload capability to your servlets and web applications. </p> <p>FileUpload parses HTTP requests which conform to RFC 1867, "Form-based File Upload in HTML". That is, if an HTTP request is submitted using the POST method, and with a content type of "multipart/form-data", then FileUpload can parse that request, and make the results available in a manner easily used by the caller, mentioned <a href="http://commons.apache.org/proper/commons-fileupload/" rel="nofollow">here</a>.</p> <p>See <a href="http://commons.apache.org/proper/commons-fileupload//using.html" rel="nofollow">this</a> link can help you more.</p> <p>Since you said -</p> <blockquote> <p>"I also need to be able to send a string (a file ID) along with the file"</p> </blockquote> <p>You will have to parse the Http request and check if the <code>FileItem</code> is a form field (string/text - file ID in your case) and process it accordingly.</p> <p>Here is the sample code for multipart content requests -</p> <pre><code>boolean isMultipart = ServletFileUpload.isMultipartContent(request); FileItemFactory factory = new DiskFileItemFactory(); FileItem item=null; ServletFileUpload servletFileUpload = new ServletFileUpload(factory); servletFileUpload.setSizeMax(-1); List items =null; if (isMultipart) { try { items = servletFileUpload.parseRequest(request); Iterator iter = items.iterator(); while (iter.hasNext()) { item = (FileItem) iter.next(); if (item.isFormField()) { //get your file Id from element to match with item.getFieldName() and do whatever you want } else if ( !item.isFormField() ){ //save your file here } </code></pre> <p>Hope that helps you.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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