DHTMLX

Get FileList from DHTMLX Form item type File

TAGs: 0 Comment

Posted By: eligeske on in DHTMLX

The DHTMLX Form item type of File creates the html element type of file. For some reason DHTMLX’s documentation now has this set as “Deprecated”.  But if you are still using this and need to get the FileList from the input to do an AJAX form post for file upload this is a quick script to use.

Requirements: 
- DHTMLX Form
- jQuery

Just after loading the dhtmlx library code add this to create a new method in the Form class.

dhtmlXForm.prototype.getItemFileList = function(name){
   return $(this.cont).find("[name='"+name+"']")[0].files;
 }

 

Usage example:

dhtmlxEvent(window,"load", function(){
     var layout = new dhtmlXLayoutObject(document.body, "1C");
     formData = [
        {type: "file", name:"myFile"}
     ];
     myForm = layout.cells("a").attachForm(formData);
 
     console.log(myForm.getItemFileList("myFile"));
});

 

0 Responses to "Get FileList from DHTMLX Form item type File"

"SHARING IS CARING"

Comments are closed.

Learning DHTMLX Suite UI

Learn the foundation of the DHTMLX Suite quickly while building a single page application with multiple components in harmony.

Popular post