c/s的没有,b/s的倒有一些,你自己参考以下;
if(upFile.PostedFile != null && !upFile.PostedFile.FileName.Equals(""))
{
string fileName = upFile.PostedFile.FileName;
int i = fileName.LastIndexOf(".");
string newExt = fileName.Substring(i);//取得文件扩展名
DateTime now = DateTime.Now;
string newName = now.DayOfYear.ToString() + upFile.PostedFile.ContentLength.ToString();
upFile.PostedFile.SaveAs(Server.MapPath("\\upload\\" + newName+newExt));
}
if(upFile.PostedFile != null && !upFile.PostedFile.FileName.Equals(""))
{
string fileName = upFile.PostedFile.FileName;
int i = fileName.LastIndexOf(".");
string newExt = fileName.Substring(i);//取得文件扩展名
DateTime now = DateTime.Now;
string newName = now.DayOfYear.ToString() + upFile.PostedFile.ContentLength.ToString();
upFile.PostedFile.SaveAs(Server.MapPath("\\upload\\" + newName+newExt));
}
这是我以前做的一个Socket练习程序,是下载而非上载,不过都是一回事。