my jps file
<form id="createGroupForm" method="POST" enctype="multipart/form-data">
<div class="row upload-create-ag-data">
<p class="ibmbr-title"><fmt:message bundle="${msg}" key="ibmDisc.title"/></p>
<div class="col-sm-6">
<input class="form-control" type="file" name="uploadFile" id="uploadFile" accept="*.xls">
</div>
<div class="col-sm-6">
<input class="btn btn-primary" type="button" style="height: 34px; margin-bottom: 5px; line-height: 0;" id="uploadGroupDetails" name="uploadGroupDetails" value='<fmt:message bundle="${pages}" key="CreateGroupFileUpload.upload"/>'/>
</div>
</div>
</form>
My Controller
@RequestMapping(value = "/CreateGroup", method = RequestMethod.POST, consumes = "multipart/form-data")
public @ResponseBody HttpServletResponse createGroup(@RequestParam(value = "uploadFile", required = true) MultipartFile uploadFile, HttpServletRequest request,
HttpServletResponse response) throws Exception {
when I submit the above form by uploading a xls file say group.xls it has been saved as XXXXXXXXX.tmp file in tomcat folder. Am trying to create a workbook using the received MultipartFile in the controller.
Workbook excelWorkBook = new HSSFWorkbook(uploadFile.getInputStream());
The above line is throwing some unknow exception. Tried multiple solution few from web and few from stackoverflow nothing worked. For example the below sol(SolFromStackoverflow) creating a file with .xls using recieved multipart file but am not able to open that .xls file, its corrupted.
String destFilePath = "/root/git/" + orgName;
File dest = new File(destFilePath);
try {
uploadFile.transferTo(dest);
boolean canRead = dest.canRead();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
First of all why spring is saving the uploaded file(group.xls) in the form of .tmp? Does mean that the file is corrupted? Please suggest if am missing anyting.
your time will be appreciated.