1

Here I am using JSP as front end and struts input tag for uploading file

My need is, To force the browser, that only list .xml and .txt extension files in open dialog and it should be browser independent (support older and newer version browser)

So far I tried this code snippet:

<td><html:file property="FileData" accept =".txt,.xml"/></td>

It's not working. Is there any other way to achieve this?

Thank you

mkj
  • 2,761
  • 5
  • 24
  • 28
user_vs
  • 1,021
  • 3
  • 16
  • 29
  • I don't think I've understood your question: you want to display the output as an XML element and not HTML? – Jack May 11 '15 at 10:21
  • when open dialog appears, in that dialog box list or show only .xml and .txt extention files only. do not show all files. – user_vs May 11 '15 at 10:34

2 Answers2

2

A quick glance at The manual says that extensions need to include the . symbol. So... accept=".txt,.xml".

Madara's Ghost
  • 172,118
  • 50
  • 264
  • 308
0

Notice dots preceeding file extensions, dots are required for it to work.

<form action="some_action.asp">
  <input type="file" name="attachment" accept=".xml, .txt">
  <input type="submit">
</form>
Mladen Oršolić
  • 1,352
  • 3
  • 23
  • 43