• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

File upload to a user defined directory

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I am usnig the orilley package to upload a file to a directory secified by a user in the HTML form.
I get the user defined directory by using the Maltipart parser as follows
MultipartParser parser = new MultipartParser(newrequest, 1024*1024);
Part part;
while ((part = parser.readNextPart()) != null)
{
name = part.getName();
if (part.isParam())
{
if(name.equals("path"))
{
ParamPart paramPart = (ParamPart) part;
value = paramPart.getStringValue();
printWriter.println(value);
}
}
}
newrequest is a copy of the InputStream of the Servlet
HttpServletRequest newrequest = request;
Then i am using the MultipartRequestobject to upload the file as follows.
MultipartRequest defaultupload=new MultipartRequest
(newrequest,value,1024*1024);
This gives me an exception as follows
Corrupt form data: premature ending
Can someone please explain how i can overcome this problem
reply
    Bookmark Topic Watch Topic
  • New Topic