页面1里面写这些
using System;
using System.Web;
public class Upload : IHttpHandler {
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
HttpFileCollection imgs = context.Request.Files;
if (imgs.Count>0)
{
for (int i = 0; i < imgs.Count; i++)
{
if (imgs[i].ContentLength!=0)
{
string oldName=imgs[i].FileName.ToString();
string imgName = Guid.NewGuid().ToString();
string imgType = oldName.ToString().Substring(oldName.LastIndexOf("."));
string imgPath = "~/upload/" + imgName + imgType;
imgs[i].SaveAs(context.Server.MapPath(imgPath));
}
}
}
}
public bool IsReusable {
get {
return false;
}
}
}
一般处理程序代码