一:在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>");
}
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。