访问被拒绝错误在IE浏览器,而文件上传 [英] Access is denied error in IE while file uploading

查看:463
本文介绍了访问被拒绝错误在IE浏览器,而文件上传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前工作的.NET下的MVC平台一个新的网站,我试图通过iframe来实现异步用户上传的图像。虽然我几乎完成了我的任务,是全功能的其他任何浏览器IE 9将失败与后续的错误:微软JScript运行时错误:访问被拒绝它看起来像一个安全关心。请允许我用下面的评论code段来形容我的问题:
1.我有它的知名度是隐藏的输入文件的HTML表单。表单里面有与一个输入元素类型=文件和一个提交按钮(也隐藏)。

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>


  1. HTML表单试图通过JavaScript文件发布到一个iframe。形式和iframe在我的本地项目(asp.net MVC)相同的域下(我在本地主机运行此)。

  1. 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).

我使用的是在输入元素上更改事件,以捕获用户选择的东西,并触发提交与Ajax调用形式。因此,当我通过javascript调用: $(#formID)提交()我得到一个拒绝访问错误

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.

任何帮助将AP preciated

Any help would be appreciated

推荐答案

我以前看到这个IE漏洞,最后我改变了我的方法.triggering输入元素的变化事件programmically考虑通过IE浏览器的安全隐患:((这么笨IE)

I saw this IE bug before,finally I changed my method .triggering change event of input element programmically consider as security risk by IE :( (so stupid IE)

在默认情况下IE不会让你触发文件元素的变化,如果你想你这个功能可以使用 ajaxuploader 或<一个HREF =htt​​ps://github.com/valums/file-uploader相对=nofollow> fileuploader

By default IE not let you trigger file element change, if you want you this feature can use ajaxuploader or fileuploader

var uploader = new qq.FileUploader({
// pass the dom node (ex. $(selector)[0] for jQuery users)
element: document.getElementById('file-uploader'),
// path to server-side upload script
action: '/server/upload'
});

这篇关于访问被拒绝错误在IE浏览器,而文件上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆