网上有很多方案,起初用时,因为对asp.net不太了解,觉得FTP实现不错,可是后来发现,如果机器在域控下,就会有问题。
一年过去了,asp.net也熟悉了,知道ajax没事应该用ashx,验证码也用ashx,当然这里要说的WinForm上传也应该是ashx了吧,哈哈,先提供简单思路:
接收文件的asp.net是:Uploader.ashx,相关代码:
usingSystem;
usingSystem.IO;
usingSystem.Web;
publicclassUploader : IHttpHandler
{
publicvoidProcessRequest(HttpContext hc)
{
foreach(stringfileKeyinhc.Request.Files)
{
HttpPostedFile file = hc.Request.Files[fileKey];
file.SaveAs(Path.Combine(hc.Server.MapPath("."), file.FileName));
}
}
publicboolIsReusable
{
get{returntrue; }
}
}
using System;
using System.IO;
using System.Web;
public class Uploader : IHttpHand