3

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!

=)

Roy Chan
  • 2,888
  • 6
  • 36
  • 43
  • I get the feeling that this is about _where to place the upload_ rather than _how to upload_. If that's the case, please clarify. – Robert Munteanu Jun 26 '09 at 14:00
  • Yes.. this is where to place the upload file. of course when I know where, I may ask how depends on the answer on where =) – Roy Chan Jun 28 '09 at 01:38

1 Answers1

4

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

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

Maurice Perry
  • 32,610
  • 9
  • 70
  • 97
  • 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 Jun 28 '09 at 01:51
  • Add a in server.xml for the uploads directory – Maurice Perry Jun 28 '09 at 17:54