• Post Reply Bookmark Topic Watch Topic
  • New Topic

Uploaded file's default location  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone tell me that what is the default location of an uploaded file using struts? Further,if I want to create a new directory in the server with the name of the directory same as that of the upoaded file,what should i do?
 
Bartender
Posts: 1843
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An uploaded file doesn't have a location.
It is not saved to disk.
All you have is a filename (no directory info) and an input stream for the file.

If you want to create a file on disk, ie save the uploaded file somewhere, then you use the standard java.io classes like FileOutputStream.

There are a couple of methods in ServletContext that might help - particularly getRealPath(). The getRealPath() method converts a website relative filename into a real location on disk. You normally use that method if you want to save the file somewhere under your web application.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!