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

ASP.NET使用SWFUpload上传大文件教学

2009-04-22 16:34 302 查看
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());
}

}
}
}

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