SpringMVC asynchronous file upload and download

First of all, let's take a look at the construction method of File:

  1.  File(String pathname): Get the File object according to a path 
  2.  File(String parent,String child): Get a File object based on a directory and a subfile/directory 
  3. File(File parent,String child): Get a File object based on a parent File object and a child file/directory 
  • java.io.File.mkdir(): Only a first-level directory can be created, and the parent directory must exist, otherwise a directory cannot be created successfully. java.io.File.mkdirs(): Multi-level directories can be created, and the parent directory does not necessarily exist

No form tags are required to implement asynchronous file uploads. The front desk purchase is:

The corresponding ajax is:

processData:false//Do not process data.

contentType:false//Do not set the content type

In addition, due to the use of ajax, it is not necessary to add its url attribute in FormData

The code behind is implemented as:

page effect:

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324668780&siteId=291194637