首页 > 编程 > .NET > 正文

asp.net 大文件上传 之 改版了的SlickUpload.HttpUploadModule(Krystalwar

2024-07-10 12:38:59
字体:
来源:转载
供稿:网友
/200905/yuanma/SlickUpload.rar
/200905/yuanma/Krystalware.SlickUpload.rar
代码如下:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Text;
using System.Reflection;
namespace Krystalware.SlickUpload
{
/**
* [[服务器端WebConfig.XML设置]]
*
* 需要在WebConfig.XML中进配置,以下结于
*<configuration>
<appSettings>
<add key="HttpUploadModulePageGoOn" value="*.*;"/>
<add key="HttpUploadModulePageJump" value="x.aspx;"/>
</appSettings>
*<system.web>
<httpModules>
<add name="HttpUploadModule" type="SlickUpload.HttpUploadModule, SlickUpload" />
</httpModules>
<httpRuntime maxRequestLength="1000000" />
*</system.web>
*</configuration>
*
[说明]
1、如果满足<HttpUploadModulePageJump>所设置的页面,则不使用大文件上传功能,直接跳出
/// 当没有设置[HttpUploadModulePageJump]则返回false;
/// 当设置[HttpUploadModulePageJump]中有[*.*;]时则返回true
/// 当设置[HttpUploadModulePageJump]中的页面等同与所要处理页面的后缀时,则返回true,否则返回false
2、如果不满足<HttpUploadModulePageJump>所设置的页面则继续进行下一判断.
3、如果满足<HttpUploadModulePageGoOn>所设置的页面,则使用大文件上传功能;否则跳出
/// 当没有设置[HttpUploadModulePageGoOn]则返回false;
/// 当设置[HttpUploadModulePageGoOn]中有[*.*;]时则返回true
/// 当设置[HttpUploadModulePageGoOn]中的页面等同与所要处理页面的后缀时,则返回true,否则返回false
*
*
**/
public sealed class HttpUploadModule : IHttpModule
{
public HttpUploadModule()
{
}
private void CleanupFiles(HttpContext context)
{
MimeUploadHandler handler1 = this.GetUploadHandler(context);
if (handler1 != null)
{
foreach (UploadedFile file1 in handler1.UploadedFiles)
{
File.Delete(file1.ServerPath);
}
handler1.UploadedFiles.Clear();
}
}
private void ClearUploadStatus()
{
HttpUploadModule.RemoveFrom(HttpContext.Current.Application, HttpUploadModule.GetUploadStatus().UploadId);
}
private void context_BeginRequest(object sender, EventArgs e)
{
HttpApplication application1 = sender as HttpApplication;
//begin: jiang zhi 2005.10.15+
//如果满足<HttpUploadModulePageJump>所设置的页面,则不使用大文件上传功能,直接跳出
if (IsJump(application1)) return;
//如果满足<HttpUploadModulePageGoOn>所设置的页面,则使用大文件上传功能;
//如果不满足<HttpUploadModulePageGoOn>所设置的页面,则不使用大文件上传功能;直接跳出
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表