FileUpload problem


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: FileUpload problem

Hybrid View

  1. #1
    Join Date
    Mar 2005
    Posts
    31

    FileUpload problem

    I have use the fileupload package and encountered error on this line in bold.

    DiskFileItemFactory factory = new DiskFileItemFactory();
    // maximum size that will be stored in memory
    factory.setSizeThreshold(4096);
    // the location for saving data that is larger than getSizeThreshold()
    factory.setRepository(new File("/tmp"));

    ServletFileUpload upload = new ServletFileUpload(factory);
    // maximum size before a FileUploadException will be thrown
    upload.setSizeMax(1000000);

    List fileItems = upload.parseRequest(request);
    // assume we know there are two files. The first file is a small
    // text file, the second is unknown and is written to a file on
    // the server
    Iterator i = fileItems.iterator();
    String comment = ((FileItem)i.next()).getString();
    FileItem fi = (FileItem)i.next();
    // filename on the client
    String fileName = fi.getName();
    // save comment and filename to database
    // write the file
    fi.write(new File("/www/uploads/", fileName));

    Error catch:
    org.apache.commons.fileupload.FileUploadBase$IOFileUploadException: Processing of multipart/form-data request failed. \tmp\upload_144f6414_11f26db7ce1__7ff8_00000000.tmp (The system cannot find the path specified)Processing of multipart/form-data request failed. \tmp\upload_144f6414_11f26db7ce1__7ff8_00000000.tmp (The system cannot find the path specified)

  2. #2
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Have you verified that the path specfied does, in fact, exist?
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  3. #3
    Join Date
    Mar 2005
    Posts
    31
    I tried to put C:/ also cannot.

    fi.write(new File("C:/", fileName));

  4. #4
    Join Date
    Feb 2009
    Posts
    2
    Hi abcat,

    you are using i.next() twice, it is creating problem to you.

    You have only item in iterator. whenever Iterator.next() method encountered, it will return the element and also pointer will start pointing to next element. Please use some refrence variable and use that instead of using i.next(). Or if you want to traverse please put a check on i.next().

Similar Threads

  1. Problem with Keydown on FileUpload control
    By ramki16 in forum ASP.NET
    Replies: 5
    Last Post: 11-17-2008, 10:13 AM
  2. Memory problem with Borland C3.1
    By AZ1699 in forum C++
    Replies: 11
    Last Post: 11-16-2007, 12:23 PM
  3. App Problem with MS Office ...
    By Shannon in forum VB Classic
    Replies: 7
    Last Post: 06-24-2007, 08:47 PM
  4. login problem
    By dbrook007 in forum ASP.NET
    Replies: 0
    Last Post: 11-06-2006, 04:54 AM
  5. Replies: 0
    Last Post: 12-13-2001, 12:06 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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center