0

I'm using an image (and input "file"-->hidden) when user clicks the image it's execute the following code:

$('#edtFile1').click(); //edtFile1 is the input for file choose...

It's working in FF, chrome and IE>8, in IE8 it's not working, I bind the click to image using jQuery 1.9 with this code:

//bind click on image-->file browse      
$("#btnimg1").click(function(event) {
    $('#edtFile1').click();
});
Ex-iT
  • 1,479
  • 2
  • 12
  • 20
user2005049
  • 510
  • 1
  • 5
  • 26
  • I’d advise to use this solution instead: http://www.quirksmode.org/dom/inputfile.html – CBroe Mar 26 '14 at 11:32

1 Answers1

0

IE does not allow the file upload control trigger operation like you did.Instead of you can do like as below.Set File Upload control opacity to 0.

<div style="position:relative;display:inline-block;left:-4px;bottom:-6px;width:16px;  height: 24px;overflow:hidden;">
<img src="/images/attach.jpg" alt="" title="Add Attachment" style="height:24px;width:16px; position: relative;top: 1px; left: 0px;"/>
<input type="file" id="fileupload" name="upload" style=" opacity: 0;font-size: 50px;width:16px; filter:alpha(opacity: 0);  position: relative; top: -22px; left: -1px" />
</div>

For further reference, please see this. In JavaScript can I make a "click" event fire programmatically for a file input element?

Demo: http://jsfiddle.net/k6zBQ/2/

Community
  • 1
  • 1
RGS
  • 5,131
  • 6
  • 37
  • 65