<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<input type="file" name="photo" id="photo" value="" placeholder="免冠照片">
<input type="button" onclick="postData();" value="下一步" name="" style="width:100px;height:30px;">
</body>
</html>
<script src="C:\Users\Administrator\Downloads\YiShaAdmin-master\YiShaAdmin-master\YiSha.Web\YiSha.Admin.Web\jquery-1.8.3.min.js"></script>
<script type="text/javascript">
function postData() {
var formData = new FormData();
formData.append("file", $("#photo")[0].files[0]);
$.ajax({
url: 'http://localhost:8080/api/powerStation/uploadMap', /*接口域名地址*/
type: 'post',
data: formData,
contentType: false,
processData: false,
success: function (res) {
console.log(res.data);
if (res.data["code"] == "succ") {
alert('成功');
} else if (res.data["code"] == "err") {
alert('失败');
} else {
console.log(res);
}
}
})
}
</script>
ajax文件上传
最新推荐文章于 2024-05-29 07:00:00 发布