0

I've seen this website. If you click on the center element, it opens a file dialog so you can upload an image. I know how to open a file dialog by using an input[type=file].

How can I open the same dialog and use its output via jQuery events (for example, a click on a div)?

2 Answers 2

1

It just invokes click on a hidden input;

<input id="fileSelector" type="file" style="visibility:hidden"/>
<div id="adiv">Click<div>

...

$(function() {
    $("#adiv").click(function() {
        $("#fileSelector").click();
    });
});
Sign up to request clarification or add additional context in comments.

Comments

0
 $("#uploadFile").click(function (e) {
      $(this.find('input[type="file"]').click();
  });

where 'uploadFile' may be the div or button which you click and input[type="file"] is the asp.net file upload control whose visibility is set as false

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.