Results 1 to 2 of 2
  1. #1
    Kelly is offline Member
    Join Date
    Mar 2010
    Rep Power

    Question Possible library problem for apache common fileupload

    Hey, I'm trying to get up a post method which takes a filepath given by the get method thought a form but for some reason its having some problem recognizing the word "File". ive underlined where im using it in my code, everything else doesnt report any errors.

    Java Code:
        protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
            DiskFileItemFactory factory = new DiskFileItemFactory();
            // maximum size that will be stored in memory
            // the location for saving data that is larger than getSizeThreshold()
            factory.setRepository(new [U]File[/U]("/tmp"));
            ServletFileUpload upload = new ServletFileUpload(factory);
            // maximum size before a FileUploadException will be thrown
                List fileItems = upload.parseRequest(request);
                Iterator i = fileItems.iterator();
                String comment = ((FileItem);
                FileItem fi = (FileItem);
                // filename on the client
                String fileName = fi.getName();
                // save comment and filename to database
                // write the file
                fi.write(new [U]File[/U]("/www/uploads/", fileName));
            }catch(Exception e){
    Im using netbeans ide 6.7 and have added the two .jar files to the library and am using the following imports.

    import java.util.*;
    import org.apache.commons.fileupload.disk.DiskFileItemFac tory;
    import org.apache.commons.fileupload.FileUpload;
    import org.apache.commons.fileupload.servlet.ServletFileU pload;
    import org.apache.commons.fileupload.portlet.PortletFileU pload;
    import org.apache.commons.fileupload.FileItem;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;

    Would really appreciate any suggestions or ideas, im probably doing something stupid but im really new to this, thanks :)

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Rep Power

Similar Threads

  1. Problem in importing org.apache
    By novice in forum New To Java
    Replies: 6
    Last Post: 05-10-2010, 07:40 PM
  2. FileUpload Error
    By sandeep.ctg in forum Web Frameworks
    Replies: 0
    Last Post: 04-07-2010, 02:06 PM
  3. Replies: 0
    Last Post: 11-15-2008, 08:29 AM
  4. problem in loading library
    By rams in forum New To Java
    Replies: 0
    Last Post: 11-04-2008, 09:19 AM
  5. problem trying to log on to my video library system
    By warship in forum New To Java
    Replies: 0
    Last Post: 07-18-2007, 03:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts