protected
void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
try
{
DiskFileItemFactory factory =
new
DiskFileItemFactory();
ServletFileUpload upload =
new
ServletFileUpload(factory);
@SuppressWarnings(
"unchecked"
)
List<FileItem> formItems = upload.parseRequest(request);
for
(FileItem item : formItems) {
if
(!item.isFormField()) {
String fileName = item.getName();
String path = request.getServletContext().getRealPath(
"/uploadFiles"
);
String filePath = String.format(
"%s/%s"
,path,fileName);
File storeFile =
new
File(filePath);
System.out.println(filePath);
item.write(storeFile);
}
}
}
catch
(Exception ex) {
}
}