<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="https://code.jquery.com/jquery-3.0.0.min.js"></script>
</head>
<body>
springmvc上传文件
<form id="form" name="form1" method="post" enctype="multipart/form-data">
<input type="file" name="upload_file" />
<input id="btn" type="button" value="springmvc上传文件" />
</form>
</body>
<script type="text/javascript">
$(function(){
$("#btn").on("click",function(){
var formData = new FormData($("#form")[0]);
$.ajax({
url: 'http://localhost:8080/shopping/upload.do',
method: 'post',
data: formData,
async: false,
cache: false,
contentType: false,
processData: false,
success:function(data){
console.log(data.data.url);
}
})
})
})
</script>
</html>
关于ajax进行form表单提交进行异步上传里面带有文件上传的问题
最新推荐文章于 2021-11-18 21:13:28 发布