0

I am using iframe for file uploading and is working fine in all browsers except IE. It says access denied on form.submit line. Please check my code below.

$(function(){
        $('.uploadBanner').click(function () {
               $('.uploadFile').trigger('click');
            });
        $(".uploadFile").on('change', function(e){  
            e.preventDefault();            
            document.getElementById('bannerUploadForm').submit();
        });  

    });

where my .uploadBanner is the click event for hidden field and .uploadFile is the hidden file type

let me know on this.

0

2 Answers 2

1

IE doesn't allow manipulation of the type="file" input element from javascript due to security reasons.

You can do a work around for this issue be detecting if the browser is ie open a file upload dialog and let the user to click on it manually

if(jQuery.browser.msie) { 
    $('#hiddenUploadForm').dialog();
}
else {
    $('.uploadFile').click();
}
Sign up to request clarification or add additional context in comments.

2 Comments

There is no problem in getting the dialog but when i select the file it fails to submit.
Dont click the file input field programmatically, instead let the user to click on it
0

IE explicitly prohibits you from programmatically opening up the file chooser dialog (by triggering a click event) and then programmatically uploading any of the selected files. The error will occur when you attempt to submit the form in this case. Let the user click the file input element instead and you will be fine. If you need to style the file input element, it's not hard to do this. Simply make it opaque and add make it the child of a div that contains the proper styling. Look around on SO or Google for specifics if needed.

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.