I constructed a basic html page to post several files to a java servlet. In the servlet I am using the apache tool fileupload to accept files, and write these to a folder.
In the code below the servlet loops through the posted files. I noticed the fileupload method (getName()) returns the complete path of the file on the users hard-drive. For example
And I am using to write the files to tomcat\files\
When it comes to writing the file an exception is thrown.
Does anyone think I should be parsen the getName() value to recieve just the file name (tree.jpg) and not the full path c:\windows\desktop\tree.jpg.
I hope this makes sense.
Iterator iter = items.iterator();
FileItem item = (FileItem) iter.next();
File uploadedFile = new File("/tomcat/files/" + item.getName());