By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,225 Members | 2,223 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,225 IT Pros & Developers. It's quick & easy.

MultipartRequest

oll3i
100+
P: 679
i try to upload a file using MultipartRequest
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.IOException: Corrupt form data: premature ending
code i use and it doesnt work
Expand|Select|Wrap|Line Numbers
  1.  try
  2. {
  3. MultipartRequest mrequest = new MultipartRequest(request, filesSavePath);
  4. Enumeration files = mrequest.getFileNames();
  5.  
  6. for (int i = 1; files.hasMoreElements( );i++)
  7.     p= mrequest.getFilesystemName((String) files.nextElement( ));
  8.  
  9.  
  10.  
  11. }
  12. catch(Exception ex)
  13. {
  14. System.out.println("Error creating file: " + ex );
  15. }
  16.  
thank You
Jan 11 '09 #1
Share this Question
Share on Google+
3 Replies


10K+
P: 13,264
What's the code for your form?
Jan 12 '09 #2

oll3i
100+
P: 679
Expand|Select|Wrap|Line Numbers
  1.     <form action="faces/result.jsp" method="POST" enctype="multipart/form-data">
  2.       <input type="file" name="cv" value="" width="50" />
  3.       <input type="submit" value="Wyślij" />
  4.       </form>
  5.  
Jan 12 '09 #3

10K+
P: 13,264
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.
Jan 13 '09 #4

Post your reply

Sign in to post your reply or Sign up for a free account.