how to specify location where uploaded files to be saved on server?
i was able to upload file from form and it was saved in my drive D: but when i change the location from "D:" to "./template" the upload will fail and i get "An error occurred when...." the webserver has "WebContent" folder and inside it has "template" folder. my understanding to String dirName = "D:"; is that when the client executes fileupload the file will just be moved to his computer's drive D: and not on the server, i want it in the server's "template" folder.. please see the code below
if (fileItem.getSize() > 0){
if (optionalFileName.trim().equals("")):confused:
fileName = FilenameUtils.getName(fileName);
else
fileName = optionalFileName;
String dirName = "D:";
File saveTo = new File(dirName + fileName);
try {
fileItem.write(saveTo);
%>
<b><font color=green>The uploaded file has been saved successfully.</font></b>
<%
}
catch (Exception e){
%>
<b><font color=red>An error occurred when we tried to save the uploaded file.</font></b>
<%