As such right now file browser is opening when we click on browse button but I want it to open when I click on any text, how can I get that? Please guide.

2 answers


See this article

Answered about 9 years ago by Neil Craig
danwellman 5600

This could be tricky as the file open text field and button are rendered by the browser as a complete unit (i.e. you don't specify a seperate input and button, just the <input> with the type set to file).

Are you saying that you want to open the choose file dialog when literally any text on the entire page is clicked? Won't that be a little confusing for your visitors?

You could do it by setting a click handler on the body which looks for clicks that originate from any <p> element, when such a click is detected (it will bubble all the up to the <body> element) all you need to do is focus the file input and that should bring up the dialog

Answered about 9 years ago by danwellman