uploadify控件在QQ、TT、firefox浏览器中不工作以及在updatecontrol中不工作的解决办法...

一:在QQ、TT浏览器中,uploadify上传控件不能正常工作,显示出了上传进度条,但是进度不走。解决办法如下,在前台初始化uploadify控件时,‘uploader’属性需要加随机数,让uploadify.swf文件重新下载到IE临时文件夹。在js中我加入了时间戳:'uploader''../js/jquery.uploadify-v2.1.4/uploadify.swf?t=' + new Date().getTime()

 

二:解决在FireFox中不工作,需要做如下4步修改:

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  { }

 } 

    

 

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

 1  < script type = " text/javascript " >
 2           function  pageLoad() {
 3               var  auth  =  $( " #<%=hfAuth.ClientID %> " ).val();
 4               var  AspSessID  =  $( " #<%=hfAspSessID.ClientID %> " ).val();
 5              $( " #uploadify " ).uploadify({
 6                   ' uploader ' ' ../js/jquery.uploadify-v2.1.4/uploadify.swf?t= '   +   new  Date().getTime(),
 7                   ' script ' ' ../JQueryUploadHandler.ashx?type=logo ' ,
 8                   ' cancelImg ' ' ../js/jquery.uploadify-v2.1.4/cancel.png ' ,
 9                   ' folder ' ' ../images/UploadFile ' ,
10                   ' queueID ' ' fileQueueImg ' ,
11                   ' auto ' true ,
12                   ' multi ' false ,
13                   ' height ' 22 ,
14                   ' buttonImg ' ' ../images/file_select.png ' ,
15                   ' fileDesc ' ' 图片文件 ' ,
16                   ' fileExt ' ' *.gif;*.jpg;*.jpeg;*.png ' ,
17                   ' removeCompleted ' true ,
18                   ' simUploadLimit ' ' 1 ' ,
19                   scriptData: { ASPSESSID: AspSessID, AUTHID: auth },
20                  onComplete:  function (event, queueID, fileObj, response, data) {
21                  alert( " 文件: "   +  fileObj.name  +   "  上传成功 " );
22                  },
23                  onError:  function (event, queueID, fileObj) {
24                      alert( " 文件: "   +  fileObj.name  +   "  上传失败 " );
25                  }
26              });
27             
28         }

29 </script>  


 

3、前台页面加入两个隐藏控件:

1  < asp:HiddenField  ID ="hfAuth"  runat ="server"   />

2 <asp:HiddenField ID="hfAspSessID" runat="server" /> 


 

4、后台pageload函数给两个隐藏控件赋值 :

1  if  ( ! IsPostBack)
2          {
3               this .hfAuth.Value  =  Request.Cookies[FormsAuthentication.FormsCookieName]  ==   null   ?
4                   string .Empty : Request.Cookies[FormsAuthentication.FormsCookieName].Value;
5               this .hfAspSessID.Value  = Session.SessionID;

 

 三:解决uploadify控件在updatepanel中不工作,需要每次updatepanel更新时,重新初始化uploadify控件,因此将初始化代码写到function pageLoad()的js函数中,并且后台pageload中加入如下代码,该行代码不能放入if (!IsPostBack)条件判定内部。

 

protected   void  Page_Load( object  sender, EventArgs e)
{
        
this .Page.RegisterClientScriptBlock( " uploadStyle " " <script>pageLoad()</script> " );

 

 

 

转载于:https://www.cnblogs.com/Teddy/archive/2011/06/14/uploadifyIssue.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值