I am currently working on a new site under .NET MVC platform and I am trying to implement an asynchronous user upload image through iframe. Although I almost complete my task and is fully functional in any other browser fails in IE 9 with the follow error: Microsoft JScript runtime error: Access is denied.
It looks like a security concern. Allow me to describe my issue using below code snippets with comments:
1. I have an html form with an input file that its visibility is hidden. Inside the form there are one input element with type="file"
and a submit button (also hidden).
<div class="brandLogo">
<p>@identity._RetailerLogo.Caption</p>
<div id="LogoContainer" class="imgLogo">
<img id ="CompanyLogo" src="@DefaultRetailerImage" alt="" title="@Model._ADD_LOGO_IMAGE">
</div>
<p class="txtR">
<a id="UploadLogo" href="#" style="position: absolute; left: -999em; top: -999em;">Upload
</a>
</p>
<form id="UploadForm"
action="@Url.Action("editLogo", "Profile")"
method="POST" enctype="multipart/form-data"
name="UploadForm"
target="UploadTarget"
style="position: absolute; left: -999em; top: -999em;">
<input name="UploadLogoFile" id="UploadLogoFile" type="file" onchange="clickUploadButton();" />
<input type="button" id="SubmitLogoForm" value="Save Image" />
</form>
<iframe id="UploadTarget" onload="UploadImage_Complete();" name="UploadTarget" style="position: absolute;
left: -999em; top: -999em;"></iframe>
The html form tries to post the file to an iframe via javascript. Both form and iframe are on my local project (asp.net mvc) under the same domain ( i run this under localhost).
I am using an on change event on the input element to capture that user selected something and to trigger the submission of the form with ajax call. So when I call via javascript:
$("#formID").submit()
I get an access denied error.
Any help would be appreciated