SpringMVC synchronous upload files

  Drip into pages, bringing together into a book.

  

1.给FORM标签增加enctype属性
  <form action="@Url.Action("RegiUser","Home")"method="post"
  enctype="multipart/form-data" >

  </ form>
The method of operation of the mapping parameters 2. adding a base class file is the last
  public ActionResult operation method name (HttpPostedFileBase.file)
  {
    physical path // Get the server to upload files
    string path = Server.MaPath ( "~ / File folder name ") +" / "+ file.fileName;
    // save the file
    file.SaveAs (path);
  }

Guess you like

Origin www.cnblogs.com/songbuqi/p/11419234.html