jQWidgets Forums
This topic contains 9 replies, has 3 voices, and was last updated by SJ 6 years, 7 months ago.
-
What version of jQWidgets are you using? [Shweta:- jQWidgets v4.1.2 (2016-Apr). This is licensed version.]
What browser does the issue occur in?[Shweta in all the browsers.]
Is (was) there a configuration (on your side) that did not cause the issue and are there other jqxFileUploads in your project that upload files as expected?
Are you sure you have made a correct use of the fileInputName property? Here is its description from the API documentation: Sets or gets the name attribute of the hidden file input which is submitted to the URL specified by the uploadUrl property. This name is applied to the file input of the file about to be uploaded and after the upload the name attribute is removed so that it can be set to the next hidden file input (if any). As a result, there is only one file input with this name attribute at a time.
[Shweta: this error is coming when i opened the jqxwindow where it has jqxfileupload feature. please see the code]
$("#uploadDatViewWindow").jqxWindow({
height : 400,
width : 400,
theme : 'bootstrap',
resizable : false,
isModal : true,
autoOpen : false,
initContent : function() {
var token = $("input[name='_csrf']").val();
var header = "_csrf";
var uu = 'uploadFile?' + header + "=" + token + "&selectedProjectId=" + document.getElementById("selectedProjectId").value + "&libName=" + selectedLibrary;
$('#jqxFileUpload').jqxFileUpload({
width : 300,
theme : 'bootstrap',
browseTemplate : 'default',
uploadTemplate : 'default',
cancelTemplate : 'default',
accept : '.txt,.xlsx,.xls,.xpt,.sas7bdat,.sas7bcat,.csv,.zip',
fileInputName : 'fileInput',
uploadUrl : uu
});
$('#eventsPanel').jqxPanel({
width : 300,
height : 150,
theme : 'bootstrap',
});
}
});
----
Click a button to open window:
if (!uploadViewDatButton.jqxButton('disabled'))
{
$("#uploadDatViewWindow").jqxWindow('open');
$('#eventsPanel').jqxPanel('clearcontent');
}
-------
Server side code:
@RequestMapping(value = "uploadFile", method = RequestMethod.POST)
public @ResponseBody String uploadFile(HttpServletRequest request, @RequestParam("fileInput") MultipartFile fileInput, @RequestParam String selectedProjectId, @RequestParam String libName) {
if (!fileInput.isEmpty()) {
try {
byte[] bytes = fileInput.getBytes();
// Creating the directory to store file
File dir = new File("\\\\sas-vm\\" + selectedProjectId + "\\Data\\" + libName + File.separator + "other");
if (!dir.exists())
dir.mkdirs();
// Create the file on server
File serverFile = new File(dir.getAbsolutePath() + File.separator + fileInput.getOriginalFilename());
BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(serverFile));
stream.write(bytes);
stream.close();
logger.info("Server File Location=" + serverFile.getAbsolutePath());
return fileInput.getOriginalFilename() + " :Successfully uploaded ";
} catch (Exception e) {
return fileInput.getOriginalFilename() + ": Failed to upload! " + e.getMessage();
}
} else {
return fileInput.getName() + ": Empty file, Failed to upload! ";
}
}