List<InputPart> inPart = formParts.get(“file”);
// “file” should
// match the name
// attribute of your
// HTML file input
for (InputPart inputPart : inPart) {
// Retrieve headers, read the Content-Disposition header to
// obtain the original name of the file
MultivaluedMap<String, String> headers = inputPart.getHeaders();
String[] contentDispositionHeader = headers.getFirst(“Content-Disposition”).split(“;”);
for (String name : contentDispositionHeader) {
if ((name.trim().startsWith(“filename”))) {
String[] tmp = name.split(“=”);
fileName = tmp[1].trim().replaceAll(“\””, “”);
}
}
}