Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invisible FileUpload control causes error on javascript postback in IE

I have asp.net webforms page with Fileupload control and image. When user clicks on image I trigger FileUpload click and when clicking ok I call __doPostBack on client side. If FileUpload is visible it works fine, but when I set style='visibility: hidden' or display: none - javascript gives error: access denied! It reproduces only in IE, not FF or chrome. Could anybody tell me how to avoid this and post the file to server? I have tried input type='file' with runat='server', non-server input-file - the result is the same...

HTML:

<input id="_ctl00_fuplImage" type="file" style="visibility: hidden" name="$ctl00$fuplImage">

JavaScript:

var fileupload = $('#<%= fuplImage.ClientID %>');

$('#<%= imgPhoto.ClientID %>').click(function() {
    fileupload.click();
});

fileupload.change(function() {
    var val = fileupload.val();
    if (val == '') return;
    __doPostBack(fileupload.attr('id'), val);
});
like image 966
idm Avatar asked May 03 '26 16:05

idm


1 Answers

It is unresolvable security issue of IE (only) that does not allow to send form with hidden file upload input. Thank you very much for your help.

like image 172
idm Avatar answered May 07 '26 09:05

idm



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!