您的位置:首页 > 编程语言 > ASP

ASP.NET使用SWFUpload上传大文件教学(源码) (转)

2009-04-11 11:33 387 查看
前段时间从网上转摘了一篇并于在ASP.NET中利用SWFUpload上传的文章,可能原文介绍也不是很详细,很多朋友发信说看不明白或者不会使用,正好在目前作的一个电子政务项目中用到了该方法,把源码贴出如下

代码很简单,有需要的朋友可以自行更改

SWFUPLOAD源码如下:

Code
protected void Page_Load(object sender, EventArgs e)
{
Response.CacheControl = "no-cache";
s_rpath = Server.UrlDecode(Request.QueryString["Path"]).Replace("\\","\\\\") ;
s_rppath = Server.UrlDecode(Request.QueryString["ParentPath"]).Replace("\\","\\\\");
if (Request.QueryString["type"] != null)
{
if (Request.QueryString["type"] == "mov")
{
DataTable dt = Sys.BasePramStart();
string Flvdir = dt.Rows[0]["flvsavepath"].ToString();
string Datedir = DateTime.Now.ToString("yy-MM-dd"); ;
string updir = Flvdir + s_rpath;
if (this.Page.Request.Files.Count > 0)
{
try
{

for (int j = 0; j < this.Page.Request.Files.Count; j++)
{

HttpPostedFile uploadFile = this.Page.Request.Files[j];

if (uploadFile.ContentLength > 0)
{
if (!Directory.Exists(updir))
{
Directory.CreateDirectory(updir);
}
string extname = Path.GetExtension(uploadFile.FileName);
string fullname=DateTime.Now.Year.ToString()+DateTime.Now.Month.ToString()+DateTime.Now.Day.ToString()+ DateTime.Now.Hour.ToString()+DateTime.Now.Minute.ToString()+DateTime.Now.Second.ToString();
string filename = uploadFile.FileName;
if (Request.QueryString["recname"] == "1")
{
filename = string.Format("{0}{1}", fullname, extname);
}
uploadFile.SaveAs(string.Format("{0}\\{1}", updir, filename));
}
}
}
catch (Exception ex)
{
Record("111", ex.ToString());
}

}
}
}

}

SWFUpload源码如下

/Files/icejd/SWFFileUpload.zip
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: