1. Create a property of type "UploadedFile" - I think that would be in package org.apache.myfaces.tomhawk.
2. Create setters and getters for it.
3. In your action processor, you can use the methods defined in
http://myfaces.apache.org/tomahawk-project/tomahawk/apidocs/org/apache/myfaces/custom/fileupload/UploadedFile.html to access the file data and metadata.
You should be aware of a couple of things, though. First, the "file name" isn't the actual name and location of the uploaded file. It's the name sent from the client. Properly speaking, it should
just be the filename itself, but apparently some versions of Internet Explorer also send the user's local filesystem path, which is A) useless to the server, since the server can't access the client's local files - only accept files the client explicitly sends. B) Dangerous, since the more outsiders know about the user's local computer setup, the more they can exploit it. C) Not portable, since Firefox plays by the rules and
doesn't send paths, so whether or not you get a simple filename or its full client absolutepath depends on what browser you use. So if you plan to actually use the uploaded filename, it's probably better to do this:
D) Some frameworks may automatically correct for Microsoft's little joke, but I don't know if Tomahawk is one of them.
If you look at the Javadocs for UploadedFile, you'll notice that there are methods for getting the contents of the uploaded file, but not the actual "file". That's because when you upload a file, it's serialized and sent as a sequence of MIME-encoded characters to the server, which then MIME-decodes the data. Although the uploaded data
may be stored in a file on the server, there's no guarantee that it is so - only that the data itself will be available for you to use (it could be stored in RAM, for example). So if you want to place this data in a server-side file, you have to use the UploadedFile's getBytes or getInputStream method to obtain the data and write it out to a server-based file that you create yourself.
Whoops - almost forgot. If you absolutely positively
must use the whole filepath from the upload and not just the filename part, please remember that Unix (Solaris, AIX,
etc.) and Linux don't have "C:" drives. So it there's even a remote chance that your code will run on a system other than Windows, handle it accordingly.
It's not very safe to mimic some other machine's filesystem structure on your server, though.
Of course, you can just as easily take that data and put it into a database BLOB/CLOB or even feed it directly into an XML SAX parser, if that works better for the job you're doing.