解决Uploadify上传控件在非IE浏览器中不工作,需要做如下2步修改:

1.Global.asax文件中,实现Application_BeginRequest函数: 

 void Application_BeginRequest(object sender, EventArgs e)
        {
            try
            {
                string session_param_name = "ASPSESSID";
                string session_cookie_name = "ASP.NET_SessionId";
                if (HttpContext.Current.Request.Form[session_param_name] != null)
                {
                    UpdateCookie(session_cookie_name, HttpContext.Current.Request.Form[session_param_name]);
                }
                else if (HttpContext.Current.Request.QueryString[session_param_name] != null)
                {
                    UpdateCookie(session_cookie_name, HttpContext.Current.Request.QueryString[session_param_name]);
                }
            }
            catch { }

            try
            {
                string auth_param_name = "AUTHID";
                string auth_cookie_name = FormsAuthentication.FormsCookieName;
                if (HttpContext.Current.Request.Form[auth_param_name] != null)
                {
                    UpdateCookie(auth_cookie_name, HttpContext.Current.Request.Form[auth_param_name]);
                }
                else if (HttpContext.Current.Request.QueryString[auth_param_name] != null)
                {
                    UpdateCookie(auth_cookie_name, HttpContext.Current.Request.QueryString[auth_param_name]);
                }
            }
            catch { }
        } 

        private void UpdateCookie(string cookie_name,string cookie_value)
        {
            HttpCookie cookie =HttpContext.Current.Request.Cookies.Get(cookie_name);
            if(null== cookie)
            {
                cookie =new HttpCookie(cookie_name);
            }
            cookie.Value= cookie_value;
            HttpContext.Current.Request.Cookies.Set(cookie);}

        } 


2. 前台js修改,注意红色代码:

//upload
        var auth = "@(Request.Cookies[FormsAuthentication.FormsCookieName]==null?string.Empty:Request.Cookies[FormsAuthentication.FormsCookieName].Value)";
        var ASPSESSID = "@(Session.SessionID )";

        $('#fileInput1').uploadify({
            'uploader''/Content/uploadify.swf?var=' + new Date().getTime(),
            'script''/Money/ImportMoneyInDue',
            'folder''/UploadFiles',
            'cancelImg''/Content/cancel.png',
            'scriptData':  { ASPSESSID: ASPSESSID, AUTHID: auth },
            'fileExt''*.xls;*.csv',
            'fileDesc''*.xls;*.csv',
            'sizeLimit'1024 * 1024 * 4//4M
            'multi'false,
            'onComplete': fun

        }); 

这样就可以了。

 

相关文章:

  • 2022-12-23
  • 2021-07-14
  • 2021-06-06
  • 2022-12-23
  • 2021-05-16
  • 2022-12-23
  • 2022-01-24
  • 2021-09-29
猜你喜欢
  • 2021-12-03
  • 2022-12-23
  • 2022-12-23
  • 2021-05-27
  • 2021-12-24
  • 2021-05-01
相关资源
相似解决方案