commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Priest <Robert.Pri...@bentley.com>
Subject RE: FileUpload Help
Date Fri, 30 May 2003 19:55:51 GMT
Yes. I did get it to work. I have it working with a jsp page.  And you have
the latest binary, correct?

The basic structure of my jsp file, using fileupload, looks something like
the following.



  .... 
 
   //set up the directory
    java.io.File uploaddir=new java.io.File(TEMP_DIR);
    uploaddir.mkdirs();


    // Create a new file upload handler
    DiskFileUpload upload = new DiskFileUpload();

    // Set upload parameters
    upload.setSizeMax(MAX_UPLOAD_SIZE);
    upload.setRepositoryPath(TEMP_DIR);

    // Parse the request
    List items = upload.parseRequest(request);
    
    
    out.print("upload called!");

....

   // Process the uploaded fields
    Iterator iter = items.iterator();
    while (iter.hasNext()) {
        FileItem item = (FileItem) iter.next();

        if (item.isFormField()) {
            out.println("<tr><td><b>Form Field<b></td><td>
Field Name:
</td><td>"+item.getFieldName()+"</td>"
            +"<td>"+  item.getString() + "</td></tr>");
        } else {
        String newFileName =
item.getName().substring(item.getName().lastIndexOf("\\")+1);
        //log comment
        logger.debug("uploading ["+newFileName+"]; from remote
ip["+request.getRemoteAddr()+"]");
        //write the file
        item.write(TEMP_DIR+"\\" + newFileName);
        //report
        out.println("<tr><td><b>File<b></td><td> File
Name:
</td><td>"+item.getName()+"</td>"
          +"<td>"+  newFileName + "</td></tr>");
        }
    } 


-----Original Message-----
From: Wilson, Allen [mailto:Allen.Wilson@marcresearch.com]
Sent: Friday, May 30, 2003 3:38 PM
To: Jakarta Commons Developers List
Subject: RE: FileUpload Help


I guess my question would be....did you get it to work? 

I used the code that was in the example provided by the binary download
and got ServletException errors. I am just trying to get a handle on how
to make things work with the API.

Allen

-----Original Message-----
From: Robert Priest [mailto:Robert.Priest@bentley.com] 
Sent: Friday, May 30, 2003 2:39 PM
To: 'Jakarta Commons Developers List'
Subject: RE: FileUpload Help


Do you have a particular question?

-----Original Message-----
From: Wilson, Allen [mailto:Allen.Wilson@marcresearch.com]
Sent: Friday, May 30, 2003 11:16 AM
To: Jakarta Commons Developers List
Subject: FileUpload Help


Has anyone used the FileUpload with any success?

I am somewhat of a Java beginner and would appreciate any assistance.

Allen

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message