# 示例

<h3>图片上传</h3>
<input type="file" name="file">

<script src="https://cdn.jsdelivr.net/npm/jquery@3.4.1/dist/jquery.min.js"></script><!-- jquery -->
<script type="text/javascript"> $(`[type='file']`).bind("change", function(){ //加载md文件 let files = this.files; if(files.length){ let file = files[0] ; let name = file.name;//读取选中文件的文件名 let size = file.size;//读取选中文件的大小 let formData = new FormData() ; formData.append("mFile" , file) ; formData.append("name" , name) ; $.ajax({ url : '/demo/upload' , type: "POST" , data: formData, processData: false , //告诉 jQuery 不要对参数进行处理 contentType: false , //高数jQuery 不要对contentType做处理,服务器会处理 success: function(result) { console.log(result) } }) ; console.log(url , name , avatar); } }); </script>
@RequestMapping("/demo/upload")
Map<String, Object> uploadFile(MultipartFile mFile) throws IOException {
    //do something...
    return null;
}

# MultipartResolver



MultipartFile