C#上传多个文件的代码

来源:百度知道 编辑:UC知道 时间:2024/06/17 05:33:32

HttpFileCollection files = Request.Files;
string fileName;
for (int i = 0; i < files.Count; i++)
{
if (files[i].ContentLength <= 0) continue;
fileName = Path.GetFileName(files[i].FileName);
string serverpath = MapPath("~/attech/" + fileName);
files[i].SaveAs(serverpath);
int size = files[i].ContentLength / 1024;
//插入数据库
}