I have been watching this
thread, but I didn't understand it, so I waited to see if someone else did.
Welcome to the Ranch, Farhan!
I think you have a misunderstanding on how file uploads work.
When you upload files using HTTP POST, you're not doing a DOS-style file copy from one machine to another. Instead, the client builds an HTTP data stream and the data that's IN the file(s) is copied into the data stream along with the HTTP headers and other protocol data.
The server receives all that data as a
unit. The file data isn't required to ever be stored in an actual file on the server. Depending on the server and its configuration, the "file" may just be something in server RAM.
The Apache API is responsible for making the file data accessible to the web application, and if it's like most such file uploads, what you'll actually be doing is obtaining a an InputStream that you can read from. You can take the data read from that stream and store it in a file, push it into a database as a BLOB, simply eat it to create your response stream, or do whatever you want to with it.
Now one thing you DON'T want to do is store that data in
Tomcat's temporary file directory. Unless you really truly want that file to be temporary. Otherwise you may look there some day and it will be deleted.
Another place you don't want to create/update a file is in your webapp's WAR directory OR within the Tomcat server itself. That's another way to lose data.
Under Unix/Linux, the common place to store uploaded data would be in an application-specific sub-directory under
/var/lib. On Windows, there is no convention, so choose whatever location is convenient for you.