Thank you Bear,
I have imported the neccessary libraries like apache's file upload and io libraries. No error on that.This is the code for the upload program.
boolean isMultipart=ServletFileUpload.isMultipartContent(request);
if(isMultipart==true){
FileItemFactory diskFactory=new DiskFileItemFactory();
ServletFileUpload uploadHandler=new ServletFileUpload(diskFactory);
try{
uploadHandler.setSizeMax(-1);
parameterList=uploadHandler.parseRequest(request);
Iterator fileIterator=parameterList.iterator();
//Process the uploaded items
while(fileIterator.hasNext()){
FileItem file=(FileItem)fileIterator.next();
String fileName="";
if(!(file.isFormField())){
String filePath=file.getName();
File resourceFile=new File(filePath);
fileName=resourceFile.getName();
File uploadedLocation=new
File(context.getRealPath("/")
+"/uploadedfiles/images"+"/"+fileName;
file.write(uploadedLocation);
}
}
}catch(Exception ex){
ex.printStackTrace();
}
Actually the context.getRealPath("/") returns like
d:\kramesh\EProductCatalogue\build\web\
and the folder I mentioned has uploadedfiles/images "/" character.
If I give "\\" to represent "\" in the directory structure file is not uploaded. If I try this program like
File uploadedLocation=new File(context.getRealPath("/")+fileName);
file.write(uploadedLocation); It works fine and files are loaded.
I hope you give me the solution.
Best Regards,
Ramesh Kangamuthu