none
在ie9下 怎么解决当地地址酿成 C:\fakepath 问题?

    问题

  •   

    <a class="btn btn-success" onclick="openfixfolder();"><i class="icon-folder-open"></i>浏览</a>
    <input type="file" id="fixfolder" style="display: none;"/>

    //浏览
                function openfixfolder(){
                    $("#fixfolder").click();
                    var rtnFlg = getPath("#fixfolder");
                    if(rtnFlg == true) {
                        $("#stage").val("2");
                        if($("#fixfolder").val()!=null&&$("#fixfolder").val()!=""){
                            var imgurll = $("#fixfolder").val().replace(/[^\u0000-\u00FF]/g,function($0){return escape($0).replace(/(%u)(\w{4})/gi,"&#x$2;")});
                            //这里要将 \ 转义一下
                            var imgname =imgurll.split("\\")[imgurll.split("\\").length-1];
                            var imgurl =  encodeURI(encodeURI($("#fixfolder").val()));
                            var imgsize = $("#fixfolder").height()*$("#fixfolder").width();
                            var Rtype = $("#Certificates_Type").val();
                            var Rname = $("#Certificates_ZB").val();
                            $("#fixfolder").val("");
                            $("#newimgurl").val(imgurl);
                            $("#newimgname").val(imgname);
                            $("#newimgsize").val(imgsize);
                            $("#newRtype").val(Rtype);
                            $("#newRname").val(Rname);
                            $("#Form").attr("action", "<%=basePath%>certificatespictures/addPictureForFile.do");
                            $("#Form").submit();
                        }
                    }
                }

    2015年12月29日 1:06

答案

  • 您好,

    由于安全的原因,我们无法使用Javascript来获取文件的全部路径,为了显示美观,我们通常把 C:\fakepath 去掉。

    var filename = $('input[type=file]').val().replace(/C:\\fakepath\\/i, '')
    Best Regards,
    Li Wang

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    2015年12月29日 8:54