Reputation: 1748
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);
});
Upvotes: 3
Views: 1913
Reputation: 1748
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.
Upvotes: 4