My web application needs to upload a file along with few other attributes to the web server
Here is relevant section in HTML
<form action = "" name = "frmSave" id = "frmSave" enctype = "multipart/form-data">Relevant part in doOnload() method reads as follows
function doOnload() {
layout = new dhtmlXLayoutObject(document.body,“2E”);
toolbar = layout.cells(“a”).attachToolbar(); //initializes dhtmlxToolbar
// load struct from xml, set icon etc
var assetForm = new dhtmlXForm(“dhxForm”);
assetForm.load(“assetFormXML.xml”,function(){
toolbar.attachEvent(“onclick”,function(id){ //attaches a handler function to the “onclick” event
if(id == “btnSubmit”) {
if(assetForm.validate()) {
alert(“submitting”);
var x = document.getElementById(“frmSave”);
x.action = “”;
x.encType = “multipart/form-data”;
x.encoding = “multipart/form-data”;
x.method = “POST”;
x.submit();
}
else
alert("----Invalid")
}
});
});
When the user clicks on “Save” present in the toolbar, the form should get submitted with all its values.
Reference links used are:
docs.dhtmlx.com/form__server_side.html and
docs.dhtmlx.com/form__controls_list.html#file (How to use section)
Now the issue/question: What happens when the user clicks button is… the servlet gets called but none of the values entered in the form are sent to the Servlet. All values are blank.
We also tried to use dhtmlxform’s send() method, but did not find any way to sent enctype to “Multipart/FormData” required for uploading a file.
Any suggestions?