Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Jakarta Commons - Using FileUpload

807606Apr 23 2007
Hello Java Experts!

I'm trying to use the FileUpload feature from Jakarta Commons 1.2 and I'm having a real tough time uploading a file to an http server and then calling that file back so that the user can view their newly uploaded file. I'm able to store the file successfully if I point my file to "C:\Temp", however if I try to point the file to "http:\\mywebserver\temp" or to a network location (which I mounted) "\\mynetwork\myfolder\temp" I get an exception FileNotFoundException.

I've searched the web and have not been able to find a resolution to this point. Any help would be greatly appreciated.

Here is my code so far:

DiskFileItemFactory fileUpload = new DiskFileItemFactory();
fileUpload.setSizeThreshold(10485760);

final String serverLocation = "http:" + "\\" + "\\webserver:8080\\temp");

ServletFileUpload upload = new ServletFileUpload(fileUpload);

// Set overall request size constraint
// Max. 4 MB : 1 MB = 1048576 bytes
upload.setSizeMax(4194305);

List items = upload.parseRequest(request);
Iterator iter = items.iterator();
while (iter.hasNext())
{
FileItem item = (FileItem) iter.next();
}

if(item.getSize() > 0)
{
File savedFile = new File(serverLocation + "test.tif");
item.write(savedFile); // This does not work, the file is never written
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 21 2007
Added on Apr 23 2007
0 comments
277 views