jQuery上传插件Uploadify 3.2使用 - 后台处理代码
<%@ WebHandler Language="C#" Class="Upfile" %>
using System;
using System.Web;
public class Upfile : IHttpHandler {
public void ProcessRequest (HttpContext context) {
//context.Response.ContentType = "text/plain";
context.Response.ContentType = "text/plain";
context.Response.Charset = "utf-8";
HttpPostedFile file = context.Request.Files["Filedata"];
//当前上传htm所在文件夹
//string uploadPath = HttpContext.Current.Server.MapPath(@context.Request["folder"]) + "\\";
string uploadPath = HttpContext.Current.Server.MapPath("../uploads") + "\\";
if (file != null)
{
if (!System.IO.Directory.Exists(uploadPath))
{
System.IO.Directory.CreateDirectory(uploadPath);
}
file.SaveAs(uploadPath + file.FileName);
//下面这句代码缺少的话,上传成功后上传队列的显示不会自动消失
context.Response.Write("1");
}
else
{
context.Response.Write("0");
}
}
#region IHttpHandler 成员
public bool IsReusable
{
get { throw new NotImplementedException(); }
}
#endregion
}