wood burning stoves 2.0*
The moose likes Servlets and the fly likes Problems uploading with Apache FileUpload Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Problems uploading with Apache FileUpload" Watch "Problems uploading with Apache FileUpload" New topic
Author

Problems uploading with Apache FileUpload

Ronaldo Nazario
Greenhorn

Joined: Sep 30, 2007
Posts: 22
Hi!

I'm having problems when testing a simple upload servlet using Apache FileUpload.
This is the code i'm using in my Servlet:



But i'm getting this error message: "\UploadedFiles (The system cannot find the path specified)"
I've tried to insert a complete file name (with name and extension, "UploadedFiles/test.pdf") when instantiating a File object, i've also tried to insert "/" at the beginning of the String, but I always end up with a similar error message.

What am I doing wrong?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42282
    
  64
Web applications do not have a concept of a default directory, so you need to use absolute paths (which begin with "/" and have the full path starting at the volume root, not the web app root).


Ping & DNS - my free Android networking tools app
Ronaldo Nazario
Greenhorn

Joined: Sep 30, 2007
Posts: 22
Thanks Ulf. I still have a question though, what is "volume root"?

So, if my application is called "MyApp" I should put "/MyApp/UploadedFiles/"? Is that correct?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42282
    
  64
what is "volume root"?

A better term would have been "file system root", as in Unix all volumes are part of a single file system hierarchy. It is the directory called "/".

if my application is called "MyApp" I should put "/MyApp/UploadedFiles/"? Is that correct?

No. You need an absolute path that starts at the file system root, which may be something like "/usr/local/bin/tomcat-5.5/webapps/MyApp/UploadedFiles", depending on where the server is installed.
Ronaldo Nazario
Greenhorn

Joined: Sep 30, 2007
Posts: 22
Thanks Ulf, I've changed the String to this path:

C:/Program Files/Apache Software Foundation/Tomcat 5.0/webapps/Webdisk/UploadedFiles

and now it's working just fine.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Problems uploading with Apache FileUpload