/// <summary> /// 获取有效客户端文件控件集合,文件控件必须上传了内容,为空将被忽略, /// 注意:Form标记必须加入属性 enctype="multipart/form-data",服务器端才能获取客户端file控件. /// </summary> public static List<HttpPostedFile> GetFileControls() { var result = new List<HttpPostedFile>(); var files = HttpContext.Current.Request.Files; if (files.Count == 0) return result; for (int i = 0; i < files.Count; i++) { var file = files[i]; if (file.ContentLength == 0) continue; result.Add(files[i]); } return result; }