MultipartRequest

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • oll3i
    Contributor
    • Mar 2007
    • 679

    MultipartRequest

    i try to upload a file using MultipartReques t
    i want to get the name of the file uploaded with html form
    and display it on jsp page (just for now to see if it works)
    in server.log i see Error creating file: java.io.IOExcep tion: Corrupt form data: premature ending
    code i use and it doesnt work
    Code:
     try
    {
    MultipartRequest mrequest = new MultipartRequest(request, filesSavePath);
    Enumeration files = mrequest.getFileNames();
     
    for (int i = 1; files.hasMoreElements( );i++)
        p= mrequest.getFilesystemName((String) files.nextElement( ));
     
     
     
    }
    catch(Exception ex)
    {
    System.out.println("Error creating file: " + ex );
    }
    thank You
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    What's the code for your form?

    Comment

    • oll3i
      Contributor
      • Mar 2007
      • 679

      #3
      Code:
          <form action="faces/result.jsp" method="POST" enctype="multipart/form-data">
            <input type="file" name="cv" value="" width="50" />
            <input type="submit" value="Wyślij" />
            </form>

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Why are you submitting to a JSP instead of to a servlet? Read the manual provided at apache's commons-fileupload site to see how it's supposed to be done.

        Comment

        Working...