| Author |
Using com.oreilly.servlet for upload to different directories
|
James Gordon
Ranch Hand
Joined: Aug 09, 2002
Posts: 106
|
|
My form allow users to upload 2 files, both to a different directories. When we create the MultipartRequest, we need to specific a location. And then, everything would go inside there. MultipartRequest m = new MultipartRequest (request, "e:/loc", 1024 * 1024); Is there anyway to go around this? Thanks in advance.
|
 |
Paul Stevens
Ranch Hand
Joined: May 17, 2001
Posts: 2823
|
|
Welcome to the JavaRanch! Please adjust your display name to meet the JavaRanch Naming Policy. You can change it here. Thanks! and welcome to the JavaRanch!
|
 |
Garann Means
Ranch Hand
Joined: Jan 28, 2002
Posts: 214
|
|
ehchn1, Does the "save directory" location have to be the absolute path? Does your code work a location like the one in your example? Thanks! g.
|
 |
Sandeep Jain
Ranch Hand
Joined: Oct 25, 2000
Posts: 124
|
|
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 .
|
Try and Try Till u succeed<br /> <br />Sandeep Jain
|
 |
Mike Curwen
Ranch Hand
Joined: Feb 20, 2001
Posts: 3695
|
|
Upload both files to a temporary holding directory, and just move them after they are uploaded. There is a related question in the cos faq: [ August 10, 2002: Message edited by: Mike Curwen ]
|
 |
James Gordon
Ranch Hand
Joined: Aug 09, 2002
Posts: 106
|
|
Hi, Thanks for all the feedbacks. I managed to get in touch with the creater of the package. According to him, I have to use the MultipartParser instead if I want more controls. Else I have to do like what Mike pointed out, which is dumping the files to a temporary directory first. But personally, I would say that the 2nd solution is not that feasible because my code would be platform dependent then. Moving the files manually is a waste of effort, thus what I can think of is by using the Runtime class to move the files automatically. To do that, I have to invoke the OS command which is not the same for all platforms. Thanks.
|
 |
Mario Rendon
Greenhorn
Joined: Jul 11, 2002
Posts: 24
|
|
Mike's Solution is the one i addopted but unfortunatelly if the client press the stop button before the file is uploaded . then in your temp dir there will be some garbage and you have to include a Garbage colection schema .. Mike have yod had that problem ??
|
 |
 |
|
|
subject: Using com.oreilly.servlet for upload to different directories
|
|
|