• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Uploaded file's default location

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic