You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ma...@apache.org on 2002/08/15 09:50:20 UTC

cvs commit: jakarta-commons-sandbox/fileupload/xdocs index.xml

martinc     2002/08/15 00:50:20

  Added:       fileupload/xdocs index.xml
  Log:
  Add documentation intro for FileUpload.
  
  Revision  Changes    Path
  1.1                  jakarta-commons-sandbox/fileupload/xdocs/index.xml
  
  Index: index.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <document>
  
    <properties>
      <title>Home</title>
      <author email="martinc@apache.org">Martin Cooper</author>
    </properties>
  
    <body>
  
      <section name="Introduction">
        <p>
          The Commons <strong>FileUpload</strong> 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
          <a href="http://www.ietf.org/rfc/rfc1867.txt">RFC 1867</a>,
          "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.
        </p>
      </section>
  
      <section name="Using FileUpload">
        <p>
          Your application should detect whether or not FileUpload should be
          invoked, based on the HTTP method and the content type of the request.
        </p>
        <p>
          Assuming that you have decided that FileUpload should be invoked, you
          might write the following code to handle a file upload request:
  <pre>
      // Create a new file upload handler
      FileUpload upload = new FileUpload();
  
      // Set upload parameters
      upload.setSizeMax(MAX_UPLOAD_SIZE);
      upload.setSizeThreshold(MAX_MEMORY_SIZE);
      upload.setRepositoryPath(TEMP_DIR);
  
      // Parse the request
      List items = upload.parseRequest(request);
  
      // Process the uploaded fields
      Iterator iter = items.iterator();
      while (iter.hasNext()) {
          FileItem item = (FileItem) iter.next();
  
          if (item.isFormField()) {
              processTextParameter(request, item);
          } else {
              processFileParameter(request, item);
          }
      }
  </pre>
        </p>
      </section>
  
    </body>
  
  </document>
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>