EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: dacracot on July 23, 2015, 08:10:35 AM



Title: How to get the files array (not the file name) from filebox component?
Post by: dacracot on July 23, 2015, 08:10:35 AM
With the HTML, <input id="HTML-GetFile" type="file"/>, I can get the get the files array via $('#HTML-GetFile').files; for each file with its name, size, etc.

But for the EasyUI component, <input id="EasyUI-GetFile" class="easyui-filebox"/> there is no files property.

This call, $('#Upload-ChooseFile').filebox('getValue'); yields only the file name.  Buried in the generated code is the array I need assessable via $('firebox_file_id_1')[0].files;, but I had to dig through the DOM to find this and I have to believe this ID, being code generated, is brittle.

What must I do to get the files array rather than just the file name directly from my filebox component?


Title: Re: How to get the files array (not the file name) from filebox component?
Post by: jarry on July 23, 2015, 08:27:41 AM
Please try the code below to get the file input element and retrieve the files array.
Code:
var f = $('#EasyUI-GetFile').next().find('.textbox-value');
console.log(f[0].files);


Title: Re: How to get the files array (not the file name) from filebox component?
Post by: dacracot on July 23, 2015, 08:43:15 AM
That worked, but is this compound statement any less brittle if I upgrade the libraries at some point in the future?