UpLoadTools.cs

using System;using System.Collections.Generic; using System.Web; using System.Web.UI; using System.IO; using System.Threading; namespace cofcms { public class UpLoadTools { public static string[] UpLoadImage(string ServerPath) { //获取所有的上传控件 var files = System.Web.HttpContext.Current.Request.Files; string[] fileall = new string[files.Count]; if (files != null) { for (int i = 0; i < files.Count; i++) { string imagename = Path.GetFileName(files[i].FileName); string fileExtension = Path.GetExtension(imagename); string image = DateTime.Now.ToString("yyyyMMddhhmmssms") + fileExtension; files[i].SaveAs(System.Web.HttpContext.Current.Server.MapPath(ServerPath) + image); fileall.SetValue(image, i); Thread.Sleep(100); } } return fileall; } } }