上传文件时拒绝访问 [英] Access Denied while uploading file

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

问题描述

嗨朋友们,

我有部分视图,用户可以在其中上传文件。以下是我的代码



部分查看:

 @model UploadeRateModel 
@ Html.ValidationSummary(true )

< iframe id =uploadTrgname =uploadTrgheight =0width =0frameborder =0scrolling =yesstyle =display:none; >< / iframe中>

@using(Html.BeginForm(UploadExchangeRate,ExchangeRates,FormMethod.Post,new {@id =UploadRateForm,@ enctype =multipart / form-data,@ target = uploadTrg}))
{
< script src =〜/ Scripts / jquery.validate.min.js>< / script>
< script src =〜/ Scripts / jquery.validate.unobtrusive.min.js>< / script>
< script>
$(document).ready(function(){
$('input [id = lefile]')。change(function(){
$('#photoCover')。val ($(this).val());
});
});
< / script>

< div id =UploadSheet_Divstyle =margin-removed20px; margin-removed8px;>
< div class =input-groupstyle =width:100%;>
@ Html.LabelFor(m => m.File,上传费率表 - 使用供应费率文件名*,新{@style =颜色:#002663;宽度:216px;显示:内联块;})
< span class =input-groupstyle =display:inline-block;>
@ Html.TextBoxFor(m => m.File,new {@id =lefile,@ type =file,@ style =display:none;})

@ Html.TextBox(File,null,new {@id =photoCover,@ class =input-large,@ type =text,@ style =border-radius:5px; margin- left:60px; vertical-align:top;})
< a class =btn> Browse< / a>


@ Html.ValidationMessageFor(m => m.File)
< / span>
< / div>
< / div>

< div style =margin-removed21px; margin-removed20px;>
< button id =btnUploadtype =submitstyle =color:white; display:inline-block; background:#00693C; border:antiquewhite; border-radius:3px; margin-left:235px ; padding:8px; margin-right:1px;> Upload< / button>
< / div>





Javascript代码:

 $ (文件).on(submit,#UploadRateForm,function(){
$('#btnUpload')。attr('disabled','disabled');
$(# uploadTrg)。unbind('load');
$(#uploadTrg)。load(function(){

var stringContent = $(this).contents()。find (pre)。html();

var objJson = jQuery.parseJSON(stringContent);

var SplittedValue = objJson.split(,);
if(SplittedValue!= null){
if(SplittedValue [0] ==true|| SplittedValue [0] ==True){
ExRateSheetableLoad(SplittedValue [1], P);
$('#SupplyDescText')。val(SplittedValue [2])
$(#UploadSheetShowDiv)。slideDown(slow);
$(# UploadSuccessMsg_Div)。slideDown(slow);
}
else if(SplittedValue [0] ==false|| SplittedValue [0] ==False){
$('#UploadErrorDiv')。show();
$('#lblUpload_Errormsg')。text(SplittedValue [1]);
}
}
$('#btnUpload')。removeAttr('disabled','disabled');
});

});
$(document).on('click',#btnUpload,function(){
var form = $('#UploadRateForm');
$(#Rate​​sheetTable_Div) .html('');
$(#UploadSuccessMsg_Div)。hide();
$(#btnUpload)。addClass(disabled);
$('# UploadErrorDiv')。slideUp();
form.submit();
返回false;

});





当我尝试使用JavaScript提交表单时,它为IE提供了Access Denied错误。它适用于休息浏览器。



有谁可以告诉我在IE中上传文件时是否存在安全问题?

什么可以解决这个问题吗?



提前致谢

解决方案

(文件).ready( function(){


('input [id = lefile]')。change(function(){


('#photoCover')。 VAL(

Hi friends,
I have a partial view where in user can upload a file. following is my code

Partial View:

@model UploadeRateModel
@Html.ValidationSummary(true)

<iframe id="uploadTrg" name="uploadTrg" height="0" width="0" frameborder="0" scrolling="yes" style="display:none;"></iframe>

@using (Html.BeginForm("UploadExchangeRate", "ExchangeRates", FormMethod.Post, new { @id = "UploadRateForm", @enctype = "multipart/form-data", @target = "uploadTrg" }))
{
    <script src="~/Scripts/jquery.validate.min.js"></script>
    <script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>
    <script>
        $(document).ready(function () {
            $('input[id=lefile]').change(function () {
                $('#photoCover').val($(this).val());
            });
        });
    </script>

<div id="UploadSheet_Div" style="margin-removed20px;margin-removed8px;">
            <div class="input-group" style="width:100%;">
                @Html.LabelFor(m => m.File, "Upload Rate Sheet- using Supply Rate File Name*", new { @style = "color: #002663;width:216px;display:inline-block;" })
                <span class="input-group" style="display:inline-block;">
                    @Html.TextBoxFor(m => m.File, new { @id = "lefile", @type = "file", @style = "display:none;" })

                    @Html.TextBox("File", null, new { @id = "photoCover", @class = "input-large", @type = "text", @style = "border-radius:5px;margin-left:60px;vertical-align:top;" })
                    <a class="btn" >Browse</a>


                    @Html.ValidationMessageFor(m => m.File)
                </span>
            </div>
        </div>

<div style="margin-removed21px;margin-removed20px;">
            <button id="btnUpload" type="submit" style="color: white; display: inline-block;background: #00693C;border: antiquewhite;border-radius: 3px;margin-left: 235px;padding: 8px;margin-right: 1px;">Upload</button>
        </div>



Javascript Code:

$(document).on("submit", "#UploadRateForm", function () {
            $('#btnUpload').attr('disabled', 'disabled');
            $("#uploadTrg").unbind('load');
            $("#uploadTrg").load(function () {

                var stringContent = $(this).contents().find("pre").html();

                var objJson = jQuery.parseJSON(stringContent);

                var SplittedValue = objJson.split(",");
                if (SplittedValue != null) {
                    if (SplittedValue[0] == "true" || SplittedValue[0] == "True") {
                        ExRateSheetableLoad(SplittedValue[1], "P");
                        $('#SupplyDescText').val(SplittedValue[2])
                        $("#UploadSheetShowDiv").slideDown("slow");
                        $("#UploadSuccessMsg_Div").slideDown("slow");
                    }
                    else if (SplittedValue[0] == "false" || SplittedValue[0] == "False") {
                        $('#UploadErrorDiv').show();
                        $('#lblUpload_Errormsg').text(SplittedValue[1]);
                    }
                }
                $('#btnUpload').removeAttr('disabled', 'disabled');
            });

        });
        $(document).on('click', "#btnUpload", function () {
            var form = $('#UploadRateForm');
            $("#RatesheetTable_Div").html('');
            $("#UploadSuccessMsg_Div").hide();
            $("#btnUpload").addClass("disabled");
            $('#UploadErrorDiv').slideUp();
            form.submit();
            return false;

        });



When I try to submit the form using JavaScript, it gives me Access Denied error for IE. It works fine for rest browser.

Can anyone tell me is there is security issue when it comes to file uploading in IE?
What can be the solution for the issue?

Thanks in advance

解决方案

(document).ready(function () {


('input[id=lefile]').change(function () {


('#photoCover').val(


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

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