public ActionResult GetForm()
        {
            HttpRequest request = System.Web.HttpContext.Current.Request;
            HttpFileCollection FileCollect = request.Files;  
            if (FileCollect.Count > 0)          //如果集合的数量大于0
            {
                foreach (string str in FileCollect)
                {
                    HttpPostedFile FileSave = FileCollect[str];  //用key获取单个文件对象HttpPostedFile
                    string imgName = DateTime.Now.ToString("yyyyMMddhhmmss");
                    string imgPath = "/" + imgName + FileSave.FileName;     //通过此对象获取文件名
                    string AbsolutePath = Server.MapPath(imgPath);
                    FileSave.SaveAs(AbsolutePath);              //将上传的东西保存
                    Response.Write("<img src='" + imgPath + "'/>");
                }
            }
            return Content("键值对数目:" + FileCollect.Count);
        }

相关文章:

  • 2021-07-18
  • 2021-06-04
  • 2021-12-04
  • 2021-11-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-13
  • 2022-02-07
  • 2022-12-23
  • 2021-09-28
  • 2022-01-22
相关资源
相似解决方案