views:

906

answers:

1

Hi Gurus,

I have been using tomcat for sometime and still can't find a good way to do file upload. Just wonder how you guys handle file upload.

You know how you can create a symlink in the application to another fs. but then by default tomcat removes your symlink and everything within the symlink. so this add extra steps to auto deployment. I know there are patch that you can change the behavior. but that will make add extra steps to tomcat upgrade, and patch might not be available always.

I use fckeditor(with it's servlet connectors), spring, struts 1/2 and sometime just plain servlet for the fileupload.

What is the best way to do this?

Another requirement is, uploaded file should be viewable and in a nice location so that backup script can backup easily, ideally not within the apps (or just a symlink within the apps)

Any comment is welcome!

=)

+3  A: 

Personally, I place the files in a location relative to $CATALINA_BASE:

File dir = new File(System.getProperty("catalina.base"), "uploads");

Maurice Perry
How to serve the files after you put the files in the $CATALINA_BASE?(Unless you write class to read from the directory and stream it?) But that defeat the purpose of using a tomcat to serve an uploaded file (cause you cannot take advantage of tomcat taking care of the range header for resume)
Roy Chan
Add a <Context> in server.xml for the uploads directory
Maurice Perry