一切福田,不離方寸,從心而覓,感無不通。

.net批量上传核心代码

            int intTotal = Request.Files.Count;
            if (intTotal > 0) {

                for (int i = 0; i < intTotal ; i++)
                {
                    HttpPostedFile file = Request.Files[i];

                    if (file.ContentLength > 0 || !string.IsNullOrEmpty(file.FileName))
                    {
                        string[] strarr = file.FileName.Split('\\');
                        string filename = strarr[strarr.GetLength(0) – 1];
                        //保存文件
                        file.SaveAs(System.Web.HttpContext.Current.Server.MapPath("./file/" + filename));
                        Response.Write(i+1+"."+filename+"<br />");
                    }
                }

            }else{
                Response.Write("得选个文件吧?");
            }