因为项目的需要,要实现按目录上传文件,百度了一下首先,文件夹本身是不能上传的,你只能在service端重建文件夹,这很好办。 上传图片你还要遍历文件夹,如下,里面还可以对图片格式进行限制 System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(Request.MapPath("./uploadfile/")); foreach (System.IO.DirectoryInfo di1 in di.GetDirectories()) { if (di1.Exists) { //这里写你的上传代码 foreach (System.IO.FileInfo fi in di1.GetFiles()) { this.globalmessage.Text = fi.Name.ToString();//换成你的上传代码 } } else { this.globalmessage.Text += "目录不存在"; } } 转载于:https://www.cnblogs.com/xinzhyu/archive/2007/06/29/799831.html