Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MultipartRequest syntax question

 
Garann Means
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm trying to use MultipartRequest to upload a file. When I get to the servlet, I get:

java.lang.IllegalArgumentException: Not a directory: /images
at com.oreilly.servlet.MultipartRequest.(MultipartRequest.java:211)
at com.oreilly.servlet.MultipartRequest.(MultipartRequest.java:106)
at com.oreilly.servlet.MultipartRequest.(MultipartRequest.java:86)
at testPad.Uploader.doPost(Uploader.java:19)........

The MultipartRequest object in the servlet is instantiated thusly:
MultipartRequest mpRequest = new MultipartRequest(request,"/images");

I also tried it without the slash, but the results were the same.
Finally, this is my directory structure:

Can anyone help me correct this? Thanks!
g.
[ August 08, 2002: Message edited by: Garann Rose Means ]
 
Sandeep Jain
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well , what I feel here there is no way u can achieve this fuctionality without modifying the MultipartRequest.java file .
So what u can do is inside the constructor of MultipartRequest file u can check for the file type or ur condition on which u want to put ur file in the respective directory and make the call to its other constructor which takes 2 parameters and can set the direcory also .
 
Sandeep Jain
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry , I just enter the comments in the wrong window, they were answer to some other question so please do not bother .
What u can try out here is give the absolute path of the directory .
 
Garann Means
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I ended up just sending an email to the contact address listed on the servlets.com website.
Jason Hunter responded:
It can be either (relative or absolute -g.). If relative it's relative to the current directory of
the web server process. Save a "foo.txt" and you'll see where that is,
or you'll get an error msg since it's very likely unwritable on Unix.

..In case anyone else was wondering the same thing.
g.
 
Malhar Barai
Author
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


MultipartRequest mpRequest = new MultipartRequest(request,"/images");


dear
what i can think is MultipartRequest doesnt hv a constructor with 2 arguments viz. (Request,PATH), make such a contstructor in Java file & then try using it...
HTH
malhar
 
Garann Means
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Malhar,
Check the JavaDoc. The first constructor is
MultipartRequest(javax.servlet.http.HttpServletRequest request, java.lang.String saveDirectory)
Constructs a new MultipartRequest to handle the specified request, saving any uploaded files to the given directory, and limiting the upload size to 1 Megabyte.

Thanks anyway.
g.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic