本文实例讲述了jQuery结合C#实现上传文件的方法。分享给大家供大家参考。具体实现方法如下:
handler1.ashx代码如下:
<%@ WebHandler Language="C#" Class="handler1" %>
using System;
using System.Web;
public class handler1 : IHttpHandler {
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
HttpPostedFile file = context.Request.Files[0];
String fileName = System.IO.Path.GetFileName(file.FileName);
file.SaveAs(context.Server.MapPath("~/") + fileName);
context.Response.Write("OK");
}
public bool IsReusable {
get {
return false;
}
}
}
希望本文所述对大家的C#程序设计有所帮助。



