How to change the "accept" value of input file on radio button click

Viewed 7088

The scenario is that I need to select which type of file I need to upload. After I have selected a file type (e.g XML) the file upload dialog box will open and filter the types of the file selected to XML only. Same goes to the other options in the radio buttons. I need to get the values selected in the radio button to be placed on the "accept" property of the file upload. Is there a way to achieve this?

HTML code here

<input type="radio" class="selectfileclass" name="file" id="xml" value="xml" />XML<br />
<input type="radio" class="selectfileclass" name="file" id="html" value="html" />HTML<br />
<input type="radio" class="selectfileclass" name="file" id="json" value="json" />JSON<br />

<span class="btn btn-default btn-file btn-primary">Browse<input type="file" id="ImportFile" accept=".xml" data-bind="event: { change: $root.Browse }"></span>
2 Answers
Related