3.2版uploadify详细例子(含FF和IE SESSION问题)
最近做项目中碰到上传需要显示进度的问题,通过uploadfiy很好的解决了这个问题不过(IE9出现了按钮不能点击的问题,至今仍找不到良策)
在使用uploadfiy3.2版本时需要下载jquery.tmpl.min.js并引用在Jquery下面

$("#uploadify").uploadify({
'uploader': '/LZKS/Handler/BigFileUpLoadHandler.ashx',
'swf': '/LZKS/Scripts/uploadify/uploadify.swf',
'cancelImage': '/LZKS/Scripts/uploadify/cancel.png',
'queueID': 'fileQueue',
//'auto': false,
'multi': true,
'buttonText': '文件上传',
'formData': { 'ASPSESSID': ASPSESSID, 'AUTHID': auth },
'onSelect': function (file) {
$('#uploadify').uploadifySettings('formData', { 'ASPSESSID': ASPSESSID, 'AUTHID': auth });
alert(formDate);
},
'onComplete': function (file, data, response) {
},
'onQueueComplete': function () {
alert("上传完成!");
$('#fileQueue').attr('style', 'visibility :hidden');
},
'onSelectError': function (file, errorCode, errorMsg) {
$('#fileQueue').attr('style', 'visibility :hidden');
},
'onUploadStart': function (file) {
$('#fileQueue').attr('style', 'top:200px;left:400px;width:400px;height :400px;visibility :visible');
}
});
});

用uplodify上传还有一个小问题就是在FF下session将会出现丢失的情况 ,在Gobal中加入如下代码来将上传过程中定义的session传至服务器上

protected void Application_BeginRequest(object sender, EventArgs e)
{
/* we guess at this point session is not already retrieved by application so we recreate cookie with the session id... */
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);
}

在JS加载前面定义下面两个变量
var auth = "<% = Request.Cookies[FormsAuthentication.FormsCookieName]==null ? string.Empty : Request.Cookies[FormsAuthentication.FormsCookieName].Value %>";
var ASPSESSID = "<%= Session.SessionID %>";

Handler文件代码如下:
public class BigFileUpLoadHandler : IHttpHandler, IRequiresSessionState
{
DALFile Fdal = new DALFile();
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
VideoUpLoad(context, CLSOFT.Web.LZKS.Edu.Globe.filename);
}
public void VideoUpLoad(HttpContext context, string fileFolderName)
{
context.Response.Charset = "utf-8";
string aaaaaaa=context.Request.QueryString["sessionid"];
HttpPostedFile file = context.Request.Files["Filedata"];
string uploadPath = HttpContext.Current.Server.MapPath(UploadFileCommon.CreateDir(fileFolderName));
if (file != null)
{
if (!Directory.Exists(uploadPath))
{
Directory.CreateDirectory(uploadPath);
}
Model.ModelFile model = new Model.ModelFile();
model.File_ID = Guid.NewGuid().ToString();
model.File_Name = file.FileName;
model.File_Path = UploadFileCommon.CreateDir(fileFolderName);
model.File_Size = file.ContentLength;
model.File_Extension = file.FileName.Substring(file.FileName.LastIndexOf('.') + 1);
model.File_Date = DateTime.Now;
model.File_CurrentMan = CLSOFT.Web.LZKS.Edu.Globe.name;
file.SaveAs(uploadPath + model.File_Name); List<Model.ModelFile> list = null;
if (context.Session["File"] == null)
{
list = new List<Model.ModelFile>();
}
else
{
list = context.Session["File"] as List<Model.ModelFile>;
}
list.Add(model);
context.Session.Add("File", list);
}
else
{
context.Response.Write("0");
}
}
//这段代码的功能是将多文件的信息存到context.Session["File"] as List<Model.ModelFileModel.ModelFile>为文件信息类
//实现批量上传的信息给Session

3.2版uploadify详细例子(含FF和IE SESSION问题)的更多相关文章
- Ubuntu 16.04安装QQ国际版图文详细教程
因工作需要,我安装了Ubuntu 16.04,但是工作上的很多事情需要QQ联系,然而在Ubuntu上的WebQQ很是不好用,于是在网上搜索了好多个Linux版本的QQ,然而不是功能不全 ...
- ThinkPHP 自动创建数据、自动验证、自动完成详细例子介绍(十九)
原文:ThinkPHP 自动创建数据.自动验证.自动完成详细例子介绍(十九) 1:自动创建数据 //$name=$_POST['name']; //$password=$_POST['password ...
- 批处理bat脚本编写(附详细例子)
批处理bat脚本编写(附详细例子) 由于在项目开发的过程中经常需要编写bat脚本,而看大牛们编写 ...
- Java 序列化Serializable详解(附详细例子)
Java 序列化Serializable详解(附详细例子) 1.什么是序列化和反序列化 Serialization(序列化)是一种将对象以一连串的字节描述的过程:反序列化deserialization ...
- MySQL5.7免安装版配置详细教程
MySQL5.7免安装版配置详细教程 一. 软件下载 Mysql是一个比较流行且很好用的一款数据库软件,如下记录了我学习总结的mysql免安装版的配置经验,要安装的朋友可以当做参考哦 mysql5.7 ...
- MySQL5.7.25解压版安装详细教程
MySQL5.7.25解压版安装详细教程 安装步骤: 1.首先,你要下载MySQL解压版,下载地址:https://www.mysql.com/downloads/,图解: 2.解压安装包,根据自己的 ...
- MySQL 5.7.20绿色版安装详细图文教程
MySQL 5.7.20绿色版安装详细图文教程 MySQL是一个关系型数据库管理系统,由瑞典MySQL AB公司开发,目前属于Oracle旗下产品.这篇文章主要介绍了MySQL 5.7.20绿色版安装 ...
- Java 序列化Serializable详解(附详细例子)
Java 序列化Serializable详解(附详细例子) 1.什么是序列化和反序列化Serialization(序列化)是一种将对象以一连串的字节描述的过程:反序列化deserialization是 ...
- Windows(x86,64bit)升级MySQL 5.7.17免安装版的详细教程
MySQL需要升级到5.5.3以上版本才支持Laravel 5.4默认的utf8mb64字符编码.因此就把MySQL升级了一下,期间还是遇到些小问题,记录一下以供参考. 升级准备 备份之前MySql目 ...
随机推荐
- .net google calendar
https://developers.google.com/gdata/client-cs http://www.codeproject.com/Articles/64474/How-to-Read- ...
- I/O 流---输出流
输出流(写入数据) a. 字节输出流 OutputStram 输出流的父类 FileOutputStream: 继承OutputStream 方法: OutputStream os=new File ...
- 关于Eigen库在Visual Studio2013中传参对齐报错问题
Error as follow: 具体问题及解决办法描述如下: (引自http://www.fx114.net/qa-278-97757.aspx) /************************ ...
- 使用nodejs搭建服务器显示HTML页面
首先安装express 在命令行输入:npm install express -g 安装完成后可以查看安装情况:npm ls -g 然后创建server.js文件 var express = requ ...
- Hibernate缓存机制简述 (转)
感谢:http://blog.csdn.net/ramln1989/article/details/5528445 ------------------------------------------ ...
- uva 1103
弄懂题意后 其实就是一个dfs /************************************************************************* > Aut ...
- IsBadStringPtr、IsBadWritePtr
判断调用进程是否拥有对指定字符串指针的读取权限,函数原型如下: BOOL IsBadStringPtr( LPCTSTR lpsz, UINT_PTR ucchMax); 参数: lpsz: 输入参数 ...
- Why does yum return error: [Errno 256] No more mirrors to try ?
https://access.redhat.com/solutions/203603 ISSUE yum update fails with the error : [Errno 256] No mo ...
- EntityFreamWork和Mvc 精品知识点
定义了DbRepository<TEntity>:IRepository<TEntity> ,SimpleDbContext继承了DbContext, UnitOfWork:I ...
- windows8 64位 IIS8 PHP5.5 安装 Imagemagick 组件
为什么这里一定要说 windows 系统是64位呢,因为如果是系统是64位,那么PHP5.5 一般都会选择64的, Imagemagick 组件也会选择64位的, 但是操蛋的是 64位的Imagema ...